| View previous topic :: View next topic |
| Author |
Message |
silveredge78
Joined: 25 Jul 2006 Posts: 382 Location: Midwest, USA
|
Posted: Fri Jul 18, 2008 8:07 pm Post subject: RegEx help needed... - [Solved] |
|
|
I am wanting to strip out several characters out of a string. I need to remove all
commas
periods
the word NULL
spaces
single & double quotes
left & right parenthesis
hyphens
from a string. I don't know RegEx expressions at all. I can do this with StringReplace, it just takes a LOT lines to do it, whereas I think this can be done with one RegEx statement.
Can someone offer some help on this? Can you try to break it down and explain what each component is so that I can learn and compare to the help file?
Thanks! _________________ SilverEdge78
Last edited by silveredge78 on Fri Jul 18, 2008 10:31 pm; edited 1 time in total |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 582 Location: MN, USA
|
Posted: Fri Jul 18, 2008 8:48 pm Post subject: |
|
|
\W = any non-word characters
| = OR
(null)+ = all occurrences of the word "null"
| Code: | string = s,t.rnull 'i"(n)g-
MsgBox,% RegExReplace(string,"\W|(null)+") |
You could also replace \W with a bracketed list of the punctuation to remove, if other punctuation should be kept. _________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
silveredge78
Joined: 25 Jul 2006 Posts: 382 Location: Midwest, USA
|
Posted: Fri Jul 18, 2008 10:31 pm Post subject: |
|
|
Exactly what I wanted!! Thanks! Instead of 8 lines of code or so, it's one. Thanks for the explanation as well.  _________________ SilverEdge78 |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 582 Location: MN, USA
|
Posted: Fri Jul 18, 2008 11:01 pm Post subject: |
|
|
I should have added the i option as well, to make "null" case-insensitive, since you did have it in all caps. | Code: | string = s,t.rNull 'i"(n)g-
MsgBox,% RegExReplace(string,"i)\W|(null)+") |
_________________ http://autohotkey.net/~jaco0646/ |
|
| Back to top |
|
 |
|