user1207960
user1207960

Reputation:

RegEx finds match correctly but returns it incorrectly

JavaScript:

var docHeadText = document.head.innerHTML;
var patt =/\/*:.+?:*\//g;
patt.compile(patt);
docHeadText.match(patt);

HTML:

<head>
<script type="text/javascript">
function JValues(){
alert('/*:hello-world:*/');
}
</script>
</head>

It returns :hello-world:*/ but I want it to return /*:hello-world:*/

Upvotes: 0

Views: 58

Answers (1)

Willem Mulder
Willem Mulder

Reputation: 13994

Use

var patt =/\/\*:.+?:\*\//g;

Upvotes: 1

Related Questions