Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keep only number in regex lines

I have a list that following is a sample of my list:

Bolt

®1421918Users

Classmates

666138Users

SixDegrees

470621Users$$

PlanetAll

AT308079Users

theGlobe

214442Users

1997

Now I want to keep only number Users from Users lines
For example:

Bolt

1421918Users

Classmates

666138Users

SixDegrees

470621Users

PlanetAll

308079Users

theGlobe

214442Users

1997

I tried following regex in notepad++ but not working:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Find What = ^.*?(\d+Users)
Replace = \1

and tried following regex:

Find What = ^(?!\d+Users).*\r?\n?
Replace = [Empty]

How to fix this regex problem?

>Solution :

You should search using this regex:

[^\n\d]*(\d*Users).*

and replace with '$1

RegEx Demo

RegEx Details:

  • [^\n\d]*: Match 0 or more of any characters that are not digit and not a line break

  • (\d*Users): Match 0 or more digits followed by text Users. Capture this value in group #1

  • .*: Match everything else till end

  • Replacement is $1 which is back-reference of capture group #1

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading