John Livermore
John Livermore

Reputation: 31343

Two regex expressions needed

Hi I am trying to match (ignore the carats as I am using those to show whitespace)...

'- go'
'. go'
'go -'
'go a'
'go &'

but not

' go'
'go'
'go '

Basically I need one expression to match any character before the word 'go' or 'GO' or 'Go' except for a whitespace.

And I need a second expression to match any character AFTER the word 'go' or 'GO' or 'Go' except for a whitespace.

Can someone help please?

Upvotes: 0

Views: 38

Answers (1)

bvgheluwe
bvgheluwe

Reputation: 853

SSMS (and Visual Studio) use a slightly different regex syntax. Well, slightly...

The first one would be:

([^:b]+):b*[gG][oO]

and the second one would be

[gG][oO]:b*([^:b]+)

Unfortunately, "0 or 1" is not supported, so there's no other way than the asterisk (0 or more). The parentheses create a capturing group for the characters you're after. :b is MS speak for a space.

Upvotes: 1

Related Questions