Friday 14 August 2015

Javascript Regex match between small brackets

One of the easiest  example to match string between two brackets is:

Javascript code
<script>
           var re = /[(](.*)[)]/;
           var m = "bool (my match)".match(re);
           if (m != null)
            alert(m[0].replace(re, '$1'));
</script>

Output:
Note
  if (m != null) is must to work properly, if there would be no match.