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

Spreadsheet RegexReplace but exclude non-number

How to RegexReplace but only for number.

enter image description here



I tried this formula, but it didn’t go as I expected:

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

=REGEXREPLACE(A2, ":<BR CLASS="""">[0-9]", ": [0-9]")



This is the sheet link:

https://docs.google.com/spreadsheets/d/1j6X0YtpTz9pnwa9woR-Q1tkStSaCfmQ67f11PiBwLBM/edit#gid=0




Thanks for your help, i really appreciate it.


>Solution :

You can use \d+ (or [0-9]+) to match one or more digits, and a capturing group (a pair of unescaped parentheses) around the pattern you want to keep, with a backreference to the group value in the replacement:

=REGEXREPLACE(A2, ":<BR CLASS="""">(\d+)", ": $1")

enter image description here

Details:

  • :<BR CLASS= – a fixed string
  • """" – a "" pattern (since a " char should be escaped with another " in a string literal in Google Sheets formula)
  • > – a > char
  • (\d+) – Capturing group 1 ($1 refers to the group value): one or more digits.
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