-2

I have large txt files which i want to import to database. I need only one : on every line.If there is more :: these characters on line i want to delete that line. Any suggestions how to do it ?. I would like to use editors as notepad++ or something similar.

    it looks like this for example

[email protected]::1234::
[email protected]:dimayacyac
[email protected]:thatcher1
[email protected]:494949
[email protected]:jacobbb:
[email protected]:brooklyn
  • Does this answer your question? [Reference - What does this regex mean?](https://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean) – AdrianHHH Sep 13 '22 at 21:06

1 Answers1

0

You can use lookarounds to do this.

^.*(?=:.*:).*$

This effectively says match everything from the start of the line ^.* to the end of the line .*$ where there are at least 2 colons on that line.

If you only want to match lines with specifically :: (no characters between them) then you can specify that in the lookaround ( ^.*(?=::).*$ ).

You can read more about lookarounds here: https://www.regular-expressions.info/lookaround.html.

Brian
  • 16