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
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
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
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.
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