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

245
Views
JavaScript If statement ERROR - null is not an object (evaluating

I am using TagUI(js based automation tool) and javascript, and while writing code to extract information from the a string I receive a "null is not an object (evaluating 'd1.match(/(Internet provider)(.*)(<br/>)/ig)[0];'

Where d1 can contain a couple of fields that I want to extract as parameters if a certain field is not available I would like to replace it with "not applicable"

examples:

d1 = "<p>please create a new entry.</p> <p>Person's name: Tom Jones<br/> Company: some company <br/> address: street one <br/> Employee ID: 07092120 <br/></p> "
OR
d1 = "<p>please create a new entry.</p> <p>Person's name: Jon Tomes<br/> Company: some company2 <br/> address: street two <br/><br/> Internet provider: O2 <br/> Employee ID: 07092121 <br/></p>"

I have tried the following expressions with no luck

provider = d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0];
if (typeof ((d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0]) === 'object' && (d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0]) !== null)){provider=(d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0]);}else{provider="not applicable"; }
if (d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0] !== null){provider="not applicable";}else{provider = d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0];}
if (typeof (provider = d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0]) !== 'string'){provider="not applicable";}else{provider=d1.match(/(Internet provider)(.*)(<br\/>)/ig)[0]; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

@VLAZ's comment did the trick:

If .match() doesn't match anything, the result is null. .match()[0] would throw an error in that case.

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!