Fusseldieb
Fusseldieb

Reputation: 59

Regex match each line that contains character

How can I make a regex that matches all new-line-characters ONLY when it begins with a " ' " character? Example:

'Hello World > Match "/n" after "d"
Hello World > No match

'Test > Match "/n" after "t"
Test > No match

'''''Xample > Match "/n" after "e"
Xample > No match

WOW 'He > Match "/n" after "e"

Thanks in advance ;)

Edit: All that I want are place tags on the BEGINNING and at the ENDING of each line that has this "comments". Like this:

WOW <blabla>'Hello<blabla>

The beginning I can just normally replace " ' " with " ' ", but the ending is a bit more difficult.

Upvotes: 1

Views: 2846

Answers (2)

alpha bravo
alpha bravo

Reputation: 7948

use this pattern

^([^']*)('+)(.*)(\r?\n|$)  

and replace w/ $1<tag>$2$3</tag>$4
Demo

Upvotes: 1

nu11p01n73R
nu11p01n73R

Reputation: 26677

How about

(^|\s)'.+$

example: http://regex101.com/r/gO0bG4/1

Upvotes: 0

Related Questions