Hi Ed,

It looks like `doc.town` is an object (at least is not `null` not
`undefined`) but that it does not have a `replace` property.

You should look at what `doc.town` is in the first place, and how you "get"
it.

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 14 December 2015 at 11:51, Ed Outhwaite wrote:

> Hi folks,
>
> I’m sure there’s a quick answer to this, but I don’t have time to keep
> trying different things.
>
> I have the results of a sparql query where ?town may or may not be
> populated (optional).
>
> If it is, I need to manipulate the results:
>
>       var town = "";
>       if (! doc.town) {
>         town = doc.town
>           .replace(/^MEIR$/,"STOKE-ON-TRENT")
>           .replace(/^COBRIDGE$/,"STOKE-ON-TRENT")
>           .replace(/^ETRURIA$/,"STOKE-ON-TRENT")
>       }
>
> I’ve tried:
>   (! doc.town)
>   (doc.town !== null)
>   (doc.town !== undefined)
>   (typeof doc.town !== undefined)
>
> But I always get: JS-JAVASCRIPT: .replace(/^MEIR$/,"STOKE-ON-TRENT”) —
> Error running JavaScript request: TypeError: undefined is not a function
>
> Time to admit I’m stumped!
>
> Help!
> Ed
>
> Ed Outhwaite
> Associate Consultant
> [email protected]
> mobile: +44 7467 954464
>
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to