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

204
Views
Find, wrap and replace occurrences in a string

I Have a list of prefixes: foo.bar. abc.

Now consider this string:

{\n\"a\":foo.bar.user.email,\n\"b\":\"abc.name\"\n}

How do I find every occurrence of substrings that start with one of my prefixes and then wrap it with ${} and remove quotes (if present)?

For example in the above string the desired output should be:

{\n\"a\":${foo.bar.user.email},\n\"b\":${abc.name}\n}

another example:

The quick abc.brown, fox jumps over the foo.bar.lazy\n"abc.dog"\n

desired output:

The quick ${abc.brown}, fox jumps over the ${foo.bar.lazy}\n${abc.dog}\n
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In a very laxed and simplified sense, you could use this as a starting point

"?(?<![a-z])((?:foo\.bar|abc)(?:\.[a-z]*)+)"?

Replace ${$1}

https://regex101.com/r/eoWkWA/1

"?
(?<! [a-z] )
(                             # (1 start)
  (?: foo \. bar | abc )
  (?: \. [a-z]* )+
)                             # (1 end)
"?
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!