Jump to content

Javascript String Regular Expression - Modifier M


Athlon

Recommended Posts

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

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

:) 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...