1

I have this regex:

([A-Za-z])\'([A-Za-z])

This works, is for example for words like : d'utilisateur (in fr)

This regex select the d'u but I just want if the condition is met, select only '.

I don't know if this is posible and how.

This is for masive replace in VS Code in plain text.

1 Answer 1

2

In Visual Studio Code, you may still use your ([A-Za-z])'([A-Za-z]) and replace with $1$2 to remove this apostrophe.

However, this won't work for consecutive matches, and you will have to use a lookahead instead of the second group. So, to remove the apostrophes in between letters use

Find What: ([A-Za-z])'(?=[A-Za-z])
Replace With: $1$2

If you need to replace with some other text, replace with $1<MY_NEW_TEXT>.

Alternatively, you may use

\b'\b

However, this pattern will also match ' in between digits and _.

Sign up to request clarification or add additional context in comments.

7 Comments

$1$2 works fine and it was that I was searching, but your regex and now is for learn not for need, don't works: regexr.com/4jn7n
@JordiCastillo You are testing the regex with the JavaScript regex engine. Why? You say you are going to use the regex in Visual Studio. Use it there.
Yeah, i tested in both sites! And remember the VS Code works with Javascript engine
@JordiCastillo you have both tags in the question, please remove the wrong one. Actually, VSCode is not using JS regex flavor. It is close to it, but not exactly the same. Also, the curent ECMAScript in Chrome supports all kinds of lookarounds and named groups.
I removed Visual studio I don't know if you refered to that
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.