check this pattern

# Thread: check this pattern

1. wd
Senior Member
Join Date
Dec 1969
Posts
141

## check this pattern

I need to match several patterns, need to make sure these look ok..<BR><BR>([1][XY]/) &#039;matches on word boundary "1" followed by "XY" <BR>d{3} &#039;matches on word boundary any 3 digits<BR>[A-Z]{6} &#039;matches on word boundary any 6 upper case chars<BR>[0-9]{3&#124 4}[A&#124P] &#039;matches &#039; &#039; either 3 or 4 digits followed by either an A or P<BR>([222]&#124[Q67]&#124[Q77] &#039;matches &#039; &#039; "222" or "Q67" or "Q77"<BR>[0]&#124[1] &#039;matches &#039; &#039; either "0" or "1"<BR><BR>these look ok?

2. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: check this pattern

I think:<BR>[0-9]{3&#124 4}[A&#124P] &#039;matches &#039; &#039; either 3 or 4 digits followed by either an A or P<BR>Should be:<BR>[0-9]{3,4}[A&#124P] &#039;matches &#039; &#039; either 3 or 4 digits followed by either an A or <BR><BR>"{3,4}" will match at least three, at most four, which is "3 or 4".

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: check this pattern

([1][XY]/) &#039;matches on word boundary "1" followed by "XY" <BR><BR>== Nope. That will look for 1 followed by X *or* Y. What&#039;s the / for?? <BR><BR>([222]&#124[Q67]&#124[Q77] &#039;matches &#039; &#039; "222" or "Q67" or "Q77"<BR><BR>== No. matches "2" or "Q or 6 or 7" or "Q or 7"<BR>== Could have accomplished exactly same thing with [2Q67]<BR>== missing right paren<BR><BR>[0]&#124[1] &#039;matches &#039; &#039; either "0" or "1"<BR><BR>== yeah, but why not just<BR>[01] <BR>???<BR><BR>********************<BR><BR>Thing s inside [...] represent *choices*! Not strings.<BR><BR>That is: [AB] is the same as A&#124B<BR>[Q67] is the same as Q&#124 6&#124 7<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Oops...missed that one...

right you are. <BR><BR>But wouldn&#039;t [A&#124P] match either A or &#124 or P ?? Don&#039;t the [...] remove the "or" quality of the &#124 ???<BR><BR>Never tried it. Obviously, it should be just [AP] and not [A&#124P]<BR><BR>

5. wd
Senior Member
Join Date
Dec 1969
Posts
141

## RE: check this pattern

I thought that anything in [] was matched as is. so If I wanted to match "222" it would have to be 222 ?

6. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: Oops...missed that one...

I do think it would remove the "or" quality, but I do not think that it would match a pipe either. To match "A" or "P" or "&#124" you would have to escape the pipe: [A&#124P]

7. Senior Member
Join Date
Dec 1969
Posts
2,885

## RE: check this pattern

nope. if you wanted to match "222", it is just that: "222" or "2{3}"

8. wd
Senior Member
Join Date
Dec 1969
Posts
141

## RE: check this pattern

ok so to match "222" or "Q33" or "Q43"<BR><BR>("737" &#124 "M8"[07]) ?

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## No quotes...

...he was just using those in his text to distinguish the limits<BR><BR>(222&#124Q[43]3)<BR><BR>would match 222 or Q33 or Q43<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## Undoubtedly correct you are.<eom>

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•