Philippe Renaud
asked on
Help with Regex 2
Hello Again EE,
Mostly for Kaufmed and TerryOpus,
with that regex:
(?<=GL_)\d+-\d+|(?<=GR_).*
what if I would like the dash to be optional after GL_ ? (dash is between some numbers)
also It might happen there would be more dashes like this:
GL_100-390-3992-1 (several dashes)
or this:
GL_9383-1384 (1 dash)
or this:
GL_1900000 (no dash)
Mostly for Kaufmed and TerryOpus,
with that regex:
(?<=GL_)\d+-\d+|(?<=GR_).*
what if I would like the dash to be optional after GL_ ? (dash is between some numbers)
also It might happen there would be more dashes like this:
GL_100-390-3992-1 (several dashes)
or this:
GL_9383-1384 (1 dash)
or this:
GL_1900000 (no dash)
ASKER
what if 0,1,2,3,4,5,....999 ?
You want to match the number if the dash is there or if it is not. If it is there, it will not be there more than once. So we need to match the dash 0 or 1 time. The matching of digits has not changed. Try it for yourself.
ASKER
Its not working if I try with this :
GL_103923-323-433334
the match will be only on : 103923-323
result would need to match: 103923-323-433334
GL_103923-323-433334
the match will be only on : 103923-323
result would need to match: 103923-323-433334
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks !
For the multiple digit-hyphen combos:
(?<=GL_)\d+(?:-\d+)*|(?<=GR_).*
(?<=GL_)\d+-{0,1}\d+|(?<=G