my notmypt
my notmypt

Reputation: 55

Match a certain string after certain character with Regex

I had a paragraph:

aaa-bbb-cc/my-text">my-text sas
//domain.com/my-text'> this is my-text

I want to replace all string 'my-text' to 'my replace tex' if they are not just after character '/' like:

aaa-bbb-cc/my-text">my replace text sas
//domain.com/my-text'> this is my replace text

Thank you

Upvotes: 1

Views: 54

Answers (1)

Shen Yudong
Shen Yudong

Reputation: 1230

(?<!\/)my-text

(?<!\/)Negative Lookbehind

since it's javascript, which does not support negative lookbehind, you can do this way:

(?=([^\/]|^)(my-text))

group 2 is your expect.

Upvotes: 2

Related Questions