Regular Expressions Newbie Question 
Author Message
 Regular Expressions Newbie Question

Any one any ideas why

var SearchPattern = new RegExp("ID19[0-9]+");

will match "ID1923" in a string

but

var SearchPattern = new RegExp("ID19\d+");

won't

I though \d was same as [0-9]

Also how do you specify a match on "ABC.+{1}"
(ie. string starting with ABC and ending with )
If the string being searched is "some text ABC123more text" it works fine
but if its
"some text ABC123more text"

I get the more which I don't want

PaulW



Sat, 29 Dec 2001 03:00:00 GMT  
 Regular Expressions Newbie Question
whatUWant="some text ABC123more text".match(/ABC.+/)


Quote:
>Any one any ideas why

>var SearchPattern = new RegExp("ID19[0-9]+");

>will match "ID1923" in a string

>but

>var SearchPattern = new RegExp("ID19\d+");

>won't

>I though \d was same as [0-9]

>Also how do you specify a match on "ABC.+{1}"
>(ie. string starting with ABC and ending with )
>If the string being searched is "some text ABC123more text" it works fine
>but if its
>"some text ABC123more text"

>I get the more which I don't want

>PaulW



Tue, 01 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Regular Expression(newbie question)

2. Regular Expressions HTML Tag Extraction (newbie)

3. Regular Expression newbie, please help!

4. Help, really simple question w/ Regular Expressions

5. Regular Expression replace question

6. Regular Expression Question

7. Regular Expression Replace Question

8. Regular expression question

9. Regular Expression question

10. Regular expressions question

11. Regular Expression replace question

12. question about regular expression

 

 
Powered by phpBB® Forum Software