Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

73
Views
Regex to match what's before or after a character in different situations

I have some troubles writing a regex

What I want to achieve, I want to match the following string 6.62 X 25.250755 L but only what is after the X character or there may be cases when I have to match the following string 25.250755 X 6.62 in this case I need to match what's before the X character and the final case is when I have something like this: 25.250755 L X 6.62 or 25.250755L X 6.62 (with or without space, with or without the L character)

This is what I have so far, but is not enough and I don't know how to continue form here on

/[Xx]([\s\S]*)$/gm
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

For your example data, you can repeat a group with a capture group to capture the value of the last iteration.

(?: ?\b(\d+(?:\.\d+)) ?[XL])+\b
  • (?: Non capture group
    • ?\b Match an optional space and a word boundary
    • ( Capture group 1
      • \d+(?:\.\d+) Match 1 or more digits with an optional decimal part
    • ) Close group 1
    • ?[XL] Match an optional space and either X or L
  • )+ Close the non capture group and repeat it 1 or more times
  • \b A word boundary

Regex demo

about 4 years ago · Juan Pablo Isaza Report

0

([0-9]*[.])?[0-9]+ ?L? X ([0-9]*[.])?[0-9]+ ?L? should work.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!