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.

asked Aug 23, 2019 at 7:16

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 _.

answered Aug 23, 2019 at 7:17
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

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.