Tuesday, October 1, 2013

Regex before a colon

I have this string:

[Provider].[Provider]=[ProviderArea].&[X12: WALES]

I want to grab just the X12 part.

I tried:

(?<=: )\w+(?=\]$)

However, this only gets WALES.

I moreover tried:

^[^:]+:\s?

But this gets the whole string before & including the colon.

Where am I going wrong?

If you wan’t to find word (\\w+) between &[ & : then try maybe

(?<=&\\[)\\w+(?=:)

No comments:

Post a Comment