-1

I tried making a regex expression to search for in the string named 'patt'. Unfortunately the following gives an error in dreamweaver:

patt.search(/.*://.*waw\d.omegle.com/);

I need to get this pattern working. What am i doing wrong here?

Nicky Smits
  • 2,980
  • 4
  • 20
  • 27
  • 1
    And what are you searching for ? – adeneo Jan 05 '15 at 16:49
  • 1
    Escape those forward slashes and periods: `patt.search(/.*:\/\/.*waw\d\.omegle\.com/)` – Joseph Marikle Jan 05 '15 at 16:51
  • 1
    Strings are delimited by quotes (`"`). What is the one character that a string literal cannot contain? Right. What do you do to embed a quote in a string? Right. The same goes for regular expression literals, only that they are not delimited by quotes. – Tomalak Jan 05 '15 at 16:51
  • You need to explain what exactly you are searching for (a couple strings maybe?). – Stratus3D Jan 05 '15 at 16:52

2 Answers2

3

You need to escape the / in the pattern as

patt.search(/.*:\/\/.*waw\d\.omegle\.com/);

Also escape . for more saftey as . alone could match anything in regex

Example

var patt = "http://asdfwaw1.omegle.com";
patt.search(/.*\/\/.*waw\d\.omegle\.com/);
=> True
nu11p01n73R
  • 26,397
  • 3
  • 39
  • 52
1

because it thinks the / in // is the end of the reg exp. If you look at the coloring in your code above you can see the brown color ends at the first slash. You need to escape it.

/.*:\/\/.*waw\d.omegle.com/;
epascarello
  • 204,599
  • 20
  • 195
  • 236