3

On Dreamweaver if I write on a Javascript document some text between two slashes like

<script type="text/javascript">
    /text/
</script>

it becomes green.

What it the meaning of this text? This is not a comment, neither "HTML text".

Thank you

user2120569
  • 187
  • 1
  • 9
  • Mozilla Regular Expression object documentation [here](https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Regular_Expressions) – dgh May 02 '13 at 19:03

3 Answers3

7

It is the regular expression literal.

From w3schools:

var patt=new RegExp(pattern,modifiers);

or more simply:

var patt=/pattern/modifiers; 

And from MDN:

RegExp(pattern [, flags])

/pattern/flags
iota
  • 34,586
  • 7
  • 32
  • 51
antoyo
  • 8,993
  • 3
  • 39
  • 69
1

It's a RegExp literal. I recommend doing your own research on the topic. I could write an introduction to finite automata and regular languages, but you'd always be able to find a better introduction with a little searching.

Keen
  • 916
  • 12
  • 19
0

You can use regular expression literals like this:

var pattern = /([0-9]+)/;
if(pattern.test(someString)) {
    // ...
} else {
    // ...
}

See also: https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Regular_Expressions

Jack
  • 1,755
  • 22
  • 28