2

Someone would know the regex expression can be used (in notepad++) in order to replace the first occurence of a characters group in each line?

eg:

abcdefg//ijkl//m.
qsdflkj//sdqlmkf//jqsmdl.

to

abcdefg\\ijkl//m.
qsdflkj\\sdqlmkf//jqsmdl.

so replace // by \\ in each line, but only the first occurence of , not the next.

If regex can't achieve it, is there another method with notepad. If not, I will code a program to split line and do the job, but need more time.

Thnaks in advance.

1
  • 2
    ^(.*?)(\/\/)(.*) with gm modifiers and substitution of $1\\$3 Commented Sep 18, 2017 at 20:28

2 Answers 2

11

Enter this regex in Find what field

(.*?)//(.*)

Enter this in Replace with field

$1\\$2

Select Regular expression in Search Mode and Uncheck . matches newline

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

3 Comments

Isn't this just a copy/rewording of my comment?
Sorry, I didn't see it before I post this. Should I delete this answer ?
Great !! works perfectly. Big thanks to Youssef13 and so @ctwheels if he is the original author....
2
  • Ctrl+H
  • Find what: ^[^/]+\K//
  • Replace with: \\\\
  • check Wrap around
  • check Regular expression
  • Replace all

Explanation:

^               : begining of line
  [^/]+         : 1 or more any character that is not a slash
  \K            : forget all we have seen until this position
  //            : 2 slashes

Replacement:

\\\\     : 2 backslashes, each one must be escaped

Result for given example:

abcdefg\\ijkl//m.
qsdflkj\\sdqlmkf//jqsmdl.

Comments

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.