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

146
Views
More concise expression possible for string query?

Is it possible (maybe using RegExp or something else) to do the following with less code?

var bTest = szNextEntity[0] == '<' && szNextEntity[1] != '/'

So bTest is true if the zeroth character of szNextEntity == '<' and the first character != '/'

Am interested in how concise this can be made.

Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could use a little regex to test the string. But in general, using regex to parse HTML is a bad idea.

Even Jon Skeet cannot parse HTML using regular expressions. Every time you attempt to parse HTML with regular expressions, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Parsing HTML with regex summons tainted souls into the realm of the living. HTML and regex go together like love, marriage, and ritual infanticide.

var re = /^<[^\/]/;

var str1 = '</end tag>';
var str2 = '<start tag>';

console.log(re.test(str1));
console.log(re.test(str2));

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!