[ create a new paste ] login | about

Link: http://codepad.org/fcVz9Bky    [ raw code | output | fork ]

Perl, pasted on Sep 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$str = "\\mbox{\sqrt{2}} + \sqrt{4}";
$str =~ s/
\\mbox{
  (
    (?:
      [^{}]+     #either match any number of non-braces
      |          #or
      \{[^{}]+}  #braces surrounding non-braces
    )*
  )
}
/$1/x;

print $str;


Output:
1
sqrt{2} + sqrt{4}


Create a new paste based on this one


Comments: