|
-
March 20th, 2008, 06:13 PM
#6
Re: regex problem
The '*' is a special character, so you should escape it if you want it as a literal: '\\*' Any character that can be used as a special character in a pattern must be escaped if you want it as a literal.
The new requirement is to match '*' and '/' (including the digits following)the same as '-' . So if you replace '-' in my expression with '*' OR '/' OR '-', you should get the result you want. The way to OR characters together is to put them inside square braces: "[]".
Regular expressions aren't really difficult - just unfamiliar. They require that you can logically express what you need to match, and then follow the regex rules exactly. The first bit is where people usually have trouble - they can't express what they want to match logically. It's hard to do because it's not something we normally have to do. The brain is so good at pattern matching, no conscious analysis is needed. When we need to explain it to a computer, paradoxically it takes a while to figure out just what it is we usually do without thinking
That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted...
G. Boole
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|