0

I have the following HTML string which I'm building using JS with help from https://jonsuh.com/blog/javascript-templating-without-a-library/:

htmlString= '<select id="DATE" type="text" value="myvalue"/><select id="FULLNAME" type="text" value="myvalue"/><select id="STREET" type="text" value="myvalue"/><select id="CITY" type="text" value="myvalue"/><select id="STATE" type="text" value="myvalue"/><select id="ZIP" type="text" value="myvalue"/><select id="FIRST" type="text" value="myvalue"/>'

I noticed that No closing select tag was produced and i decided to substitute in in using:

htmlString.replace(/\/>/g,">options_go_here</option>");

The regex looks right to me : https://regex101.com/r/gJLrhR/2

However I see no change in the string. What am I doing wrong ?

user1592380
  • 34,265
  • 92
  • 284
  • 515
  • Did you assign the new string back to `htmlString`? Also, don't even try to [parse HTML with Regexp](https://stackoverflow.com/a/1732454/). – Derek 朕會功夫 Sep 15 '17 at 23:28
  • Hm, templating HTML with strings and regular expression doesn't really sound like a very good idea, and brings b̤͖͢a̠̹̥͘cḵ͓̳̣͘ ͡h̲̀ò̩̞͖̮ŕ̻̦͔r̙̣̘̮̦̩̀i͔͙̦̼̱̳b̳̰̫͉l̤͠e̳͚̯͕͈ ̩͘m̟̤̼e͕m̴̫̲o̥͇͍̖ͅr̞͜i̢̭͍̬̟̥ḙ̷̼̬̰̝̠s̱͍̜̱͈̞ of Tony the Pony – adeneo Sep 15 '17 at 23:31
  • Derek You were right, thank you! – user1592380 Sep 15 '17 at 23:55
  • I'm working with apps script on the server side, which does not have support for HTML, so I have to build the HTML dynamically using strings. – user1592380 Sep 16 '17 at 15:30

0 Answers0