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]; }