Manik Mahajan
Manik Mahajan

Reputation: 1624

Suggest regular expression

Can some one suggest regular expression for below text

Signature

text text some more text

text

...

text )

I tried Signature\n.*\) but this only works for

Signature
text )

Basically an expression which starts with a given text, allows multiple new lines, and ends with ).

Thanks

Upvotes: 0

Views: 167

Answers (4)

Bart Kiers
Bart Kiers

Reputation: 170178

Flex supports negated character classes, so you could do:

/* definition section */

%%

Signature[^)]*\) { /* custom code */ }

%%

/* user subroutines */

Upvotes: 0

Shekhar
Shekhar

Reputation: 11788

You can use following regex

\bSignature[\s\S]*?[)]

This regex will first look at Signature, followed by any character which includes alphanumeric characters, \n , etc followed by )

Upvotes: 0

Kobi
Kobi

Reputation: 138037

The problem is that . doesn't match new-lined by default.

A simple option is:

/signature[^)]*\)/i

[^)]* will match all characters besides ).

I'm not sure if you have a Dot-All flag in flex. In JavaScript the /s flag is missing, and the common work around is:

/signature[\s\S]*?\)/i

In this case, you probably want to use a lazy quantifier, *?, so you match until the first ), and not the last.

Upvotes: 4

noj
noj

Reputation: 139

try

var pattern:RegExp = /^Signature.+\\)/m;

Upvotes: 0

Related Questions