6

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
  • 227
  • 1
  • 3
  • 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

8

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
Unmitigated
  • 76,500
  • 11
  • 62
  • 80
antoyo
  • 11,097
  • 7
  • 51
  • 82
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
  • 954
  • 12
  • 19
-1

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,881
  • 24
  • 29