How to clean the details with regex?

i want to delete the details on regex

  • I have a lot of accounts, and I want to remove all the details [email protected] | example1 | Personal[US] | Verified | | No SMART | No Bank | No Card | Example1 | Example2 | Example3 | Checked on https://www.example.com at 1:43 pm - September 6, 2015 [email protected] | example2 | Personal[US] | Verified | | No SMART | No Bank | No Card | Example1 | Example2 | Example3 | Checked on https://www.example.com at 5:33 pm - September 6, 2015 [email protected] | example3 | Personal[US] | Unverified | | No SMART | No Bank | No Card | Example1 | Example2 | Example3 | Checked on https://www.example.com at 5:35 pm - September 6, 2015 and i want to delete like this [email protected]|example1 [email protected]|example2 [email protected]|example3 question , whats code on regular expression to mass delete?

  • Answer:

    You can use the following replacement: Regex: ^([^|]*?)\s*\|\s*([^|]*).* Replacement: \1|\2 See https://regex101.com/r/nT3qP6/1 The regex will match the ^ - start of string ([^|]*?) - 0 or more characters other than | as few as possible (Group 1 - \1) \s*\|\s* - optional whitespace symbols, |, and again optional whitespace symbols ([^|]*) - 0 or more characters other than | (Group 2 - \2) .* - 0 or more symbols other than newline With the back-references to the captured groups, we get our replacement string.

Ÿøga Aprillianšyah N at Stack Overflow Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.