![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) |
| Guest | Re: Simple Regular Expression Technically, it is correct. Looking just at the last bit, you asked it to match 4 digits, and there were 4 digits. There was also another digit, but that was not part of the match. If you want the entire string to match from beginning to end, try: $expression = "^[a-z]{3}\-[a-z]{2}\-[0-9]{4}$" -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "BJ" <post@xxxxxx> wrote in message news:1b523a23-05d3-4dc0-9285-9a4f7ad00eb7@xxxxxx Hello Group, This string matches although the number has 5 digits. What's wrong? $string = "NYC-CC-35225" $expression = "[a-z]{3}\-[a-z]{2}\-[0-9]{4}" $string -match $expression |
| | #3 (permalink) | ||||||||||||
| Guest | Re: Simple Regular Expression Thank you very much, it works! It will take a long time to get used to regular expressions, especially for a newbie like myself....... On 30 Jan., 20:32, "Tom Moreau" <t...@xxxxxx> wrote:
| ||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Simple Regular Expression The problem for me is that I am a Perl jock and the syntax for Perl vs. MS regular expressions is somewhat different. I was looking for negative and positive look-ahead and look-behind and couldn't come up with what I wanted. -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "BJ" <post@xxxxxx> wrote in message news:026e669a-dc07-4fa1-b586-7a99bcff4944@xxxxxx Thank you very much, it works! It will take a long time to get used to regular expressions, especially for a newbie like myself....... On 30 Jan., 20:32, "Tom Moreau" <t...@xxxxxx> wrote:
| ||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Simple Regular Expression Here's the .NET syntax ![]() (?= ...) Positive lookahead (?! ...) Negative lookahead (?<= ...) Positive lookbehind (?<! ...) Negative lookbehind ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: Simple Regular Expression Thanx. Looks like it's the same as Perl. Have you got a link to this at the MSDN site? -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA, MCITP, MCTS SQL Server MVP Toronto, ON Canada https://mvp.support.microsoft.com/profile/Tom.Moreau "Shay Levi" <no@xxxxxx> wrote in message news:8766a9441c84f8ca31a6cfa302f8@xxxxxx Here's the .NET syntax ![]() (?= ...) Positive lookahead (?! ...) Negative lookahead (?<= ...) Positive lookbehind (?<! ...) Negative lookbehind ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: Simple Regular Expression http://msdn2.microsoft.com/en-us/library/ms972966.aspx ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regular expression help | Stimp | VB Script | 9 | 08-02-2008 06:05 PM |
| Results from Regular Expression Match | Mike | PowerShell | 2 | 05-20-2008 08:26 PM |
| Re: regular expression howto | Keith Hill [MVP] | PowerShell | 0 | 01-08-2008 09:45 PM |
| Regular expression notes | John Cook | PowerShell | 2 | 07-13-2007 04:10 PM |
| simple regular expression | Ben | PowerShell | 2 | 02-19-2007 08:28 AM |