问题描述:

I'm trying to create a parser that will scan an entire text for lines that start with either "ACTIE" or "TODO" after which it returns the rest of the line except for the word at the start

Example:

This is an example text

ACTIE this should be returned

more text etc.

should return:

this should be returned

The regex I have created so far is:

\s*(\bACTIE|TODO\b) ([^\n\r]*)

which returns both ACTIE and the line after it as two hits:

ACTIE, this should be returned

Is there any way I can let it drop "ACTIE" or "TODO" at the start and only have it return the rest of the line?

网友答案:

Use a non-capturing group:

\s*(?:\bACTIE|TODO\b) ([^\n\r]*)
相关阅读:
Top