Ignoring spaces and punctuation
Posted: Wed Feb 08, 2006 1:56 pm
I'm looking for a way to have my regex account for variations in spacing/punctuation. For example, if I'm looking for "gradepoint", I would want "gradepoint", "grade point", "grade-point", "gr.ade-po!i?nt." etc. all to match.
(Please note that this is only an example -- I can't be this specific in the actual code, which scans a block of text for any of thousands of keywords.)
First question -- is there a simple way to just say "ignore punctuation", like you can add "i" at the end to have it ignore case?
If not, then I think I'm looking at something like this: (in English, using the "gradepoint" example)
letter G, possibly a non-alphanumeric character, letter R, possibly a non-alphanumeric character, letter A.... and so on.
What would be the syntax for this?
Thanks!
(Please note that this is only an example -- I can't be this specific in the actual code, which scans a block of text for any of thousands of keywords.)
First question -- is there a simple way to just say "ignore punctuation", like you can add "i" at the end to have it ignore case?
If not, then I think I'm looking at something like this: (in English, using the "gradepoint" example)
letter G, possibly a non-alphanumeric character, letter R, possibly a non-alphanumeric character, letter A.... and so on.
What would be the syntax for this?
Thanks!