[Javascript] OT: RegExp
Flavio Gomes
flavio at economisa.com.br
Wed May 12 13:26:54 CDT 2004
GodLike, Thank You!
--
Flavio Gomes
flavio at economisa.com.br
Shawn Milo wrote:
>I don't think it's off-topic -- it's still Javascript.
>
>Here is the code:
>
> var someQuery = "select name, (select 'subselect', 2+2 as sum, 5*3 as product from my_table) from another_table where number = (select id_nro from third_table where birthdate is not null)"
>
> document.write(someQuery + '<br/>');
>
> someQuery = someQuery.replace(/\([^)]*\)/g, '');
>
> document.write(someQuery + '<br/>');
>
>
>explanation of regex:
>
>find a ( followed by anything that is not a ) for any number of characters (including zero),
>followed by a ). Replace the entire thing with an empty string.
>
>The '(' and ')' are escaped '\(' and '\)' because parenthesis have
>meaning in regexes.
>
>Shawn
>
>
More information about the Javascript
mailing list