| Long time no posting! I've a regex question!
|
Matthew1980

msg:4550391 | 11:47 am on Mar 2, 2013 (gmt 0) | HI there people, Crikey, feels like ages since i've posted on here, hope as everyone is having a good time :) Business: Simple regex: ^[A-Z]/[A-Z]{2}[0-9]{3}/[0-9]{2}$ This checks for - AP/PD123/13, how can I change this to add an either or type operator in there, sort of like this:- ^[A-Z]/[A-Z]{2}[0-9]{3}/[0-9]({2}|{3})$ I'm sure that this is correct, but it's not reacting to the change. ? Thanks in advance. Cheers, MRb
|
g1smd

msg:4550437 | 2:22 pm on Mar 2, 2013 (gmt 0) | Beginning ^[A-Z]/ it does NOT match two letters, only one. "two or three digits" is done with [0-9]{2,3} Welcome back!
|
Matthew1980

msg:4550449 | 2:50 pm on Mar 2, 2013 (gmt 0) | Hi there g1smd, Sorry, that was down to sloppy copy n pasting! Thanks for the solution there too, I'm not brilliant at doing regex & I thought as the | would work like it does in C. There I go assuming again lol! Thanks for the welcome back there too. Cheers, MRb
|
g1smd

msg:4550455 | 3:24 pm on Mar 2, 2013 (gmt 0) | /([0-9]{2}|[0-9]{3})$ would work, but the general rule is "when something repeats, stuff can be combined", hence
/[0-9]{2,3}$ instead.
|
Matthew1980

msg:4550546 | 10:12 pm on Mar 2, 2013 (gmt 0) | Hi g1smd, I've just tested it, and it works great; I opted for the 'short-hand' version, and I've now combind an array of possible combinations down to 4 opposed to 8. Thanks for the help once again! Cheers, MRb
|
g1smd

msg:4550561 | 12:40 am on Mar 3, 2013 (gmt 0) | There was a longer thread about combining things only yesterday or the day before. Might be some extra clues in there too!
|
|
|