Athlon Posted January 9, 2010 Share Posted January 9, 2010 This is the code i typed to match the word George in dreamweaver. Can any one explain me how that match works or if there is any error in my code? Probably i didnt understan how modifier works <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><script type="text/javascript">var x="<pre> there is a hero named george, that guy safed thousand of women children from the evil.he is known in the west as the great George of cyprus. </pre>"var c=/George/mdocument.write(c.match(x))</script></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted January 10, 2010 Share Posted January 10, 2010 In Javascript you can't have a linebreak in a string. You either need to put your string on one line or take more than one to define the variable: var x="<pre> there is a hero named george, that guy safed thousand of women children from the evil.\nhe is known in the west as the great George of cyprus. </pre>" var x="<pre> there is a hero named george, that guy safed thousand of women children from the evil.\n";x += "he is known in the west as the great George of cyprus. </pre>" Link to comment Share on other sites More sharing options...
Athlon Posted January 15, 2010 Author Share Posted January 15, 2010 emmmm can you explain that code you typed in order to break the line? I used the tag <pre> make my text into 2 lines. As you told me that was false. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 15, 2010 Share Posted January 15, 2010 I left out a semicolon there, but you can just use the concatenation operator to build your string.var str = 'some text';str += 'more text';str += 'still more text';alert(str); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.