| View previous topic :: View next topic |
| Author |
Message |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Wed May 06, 2009 10:55 am Post subject: Inverting regsub's functions |
|
|
Hey guys,
I'm using regsub to check if a variable matches a regular expression and if it does, regsub will replace the part that matches by what I want and assign that to a new variable
however, I wanted to make the opposite. I want regsub to assign the part of the variable that matched the regular expression to a variable. How can I do this? |
|
| Back to top |
|
 |
Papillon Owner

Joined: 15 Feb 2002 Posts: 724 Location: *.no
|
Posted: Wed May 06, 2009 2:03 pm Post subject: |
|
|
Use Regexp
| Code: | set txt SomeTextHere
regexp -all {Text} $txt new |
$new will contain the match, in this case "Text" _________________ Elen sila lúmenn' omentielvo |
|
| Back to top |
|
 |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Fri May 08, 2009 7:52 am Post subject: |
|
|
| ahmmm, nice, thanks a lot! |
|
| Back to top |
|
 |
|