• Home
  • Jobs
  • Courses
  • Questions
  • Teachers
  • For business
  • ES/EN

0

14
Views
check if string contains balanced single braces, contains solely balanced double braces should return false

I am trying to write a regex test in JavaScript to check if a string solely contains balanced single braces, solely containing balanced double braces should return false.

For example:

  • if the string is "{something}", "abc{something}cbd", it should return true,

  • if the string is "{something}abc{{somethingElse}}", "{{somethingElse}}{something}", it should also return true,

  • however, if the string is "{{something}}" or "{{something}}abc{{somethingElse}}", it should return false

I have a regex solution for this, which is /(?<!{\s?){(?!\s?{)[^{}]+(?<!}\s?)}(?!\s?})/gm, however ios safari doesn't support negative lookbehind.

about 1 month ago ·

Juan Pablo Isaza

Answer question
Find remote jobs
Loading

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2022 PeakU Inc. All Rights Reserved.