Обсуждение: regexp_replace() function in new version
Hi,
regexp_replace() function in new version of PostgreSQL is giving error.
I am trying to remove tags from string.
I have tried following regex in & function:
----
Thanks & Regards,
Abhijeet G. Rathod
Software Engineer -(SCWCD)
Mail: abhijeetrathod262@gmail.com
-----------------------------------------------------------
Dreamers of the day are dangerous men,
because they make their dreams happen.
-----------------------------------------------------------
regexp_replace() function in new version of PostgreSQL is giving error.
I am trying to remove tags from string.
I have tried following regex in & function:
- SELECT regexp_replace('<i>Abhijeet</b>', '<(\s)*/?(?i:script|i|b|u|embed|object|a|frameset|frame|iframe|meta|link|style|table|th|td|tr|tbody|input|select|option|form|map|area|!--)(.|\n)*?>', '\&\s');
- cc SELECT regexp_replace('<i>Abhijeet</b>', '< */?(?i:script|i|b|u|embed|object|a|frameset|frame|iframe|meta|link|style|table|th|td|tr|tbody|input|select|option|form|map|area|!--)(.|\n)*?>', '\& ' );
- WARNING: nonstandard use of escape in a string literal at character 42
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
WARNING: nonstandard use of escape in a string literal at character 192
HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
ERROR: invalid regular expression: quantifier operand invalid
----
Thanks & Regards,
Abhijeet G. Rathod
Software Engineer -(SCWCD)
Mail: abhijeetrathod262@gmail.com
-----------------------------------------------------------
Dreamers of the day are dangerous men,
because they make their dreams happen.
-----------------------------------------------------------
On Nov 14, 2007 7:53 AM, Abhijeet <abhijeetrathod262@gmail.com> wrote: > Hi, > > regexp_replace() function in new version of PostgreSQL is giving error. > > I am trying to remove tags from string. > > I have tried following regex in & function: > > SELECT regexp_replace('<i>Abhijeet</b>', > '<(\s)*/?(?i:script|i|b|u|embed|object|a|frameset|frame|iframe|meta|link|style|table|th|td|tr|tbody|input|select|option|form|map|area|!--)(.|\n)*?>', > '\&\s'); > cc SELECT regexp_replace('<i>Abhijeet</b>', '< > */?(?i:script|i|b|u|embed|object|a|frameset|frame|iframe|meta|link|style|table|th|td|tr|tbody|input|select|option|form|map|area|!--)(.|\n)*?>', > '\& ' ); Both these try giving me error as follows: > > > WARNING: nonstandard use of escape in a string literal at character 42 > HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. > WARNING: nonstandard use of escape in a string literal at character 192 > HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. > ERROR: invalid regular expression: quantifier operand invalid can anyone > suggest me why is that error ocurring? I think PostgreSQL is telling what's happening in the hint there. Put an E in front of your strings if you're going to have escapes in them.
Abhijeet <abhijeetrathod262@gmail.com> writes: > I have tried following regex in & function: > - SELECT regexp_replace('<i>Abhijeet</b>', > '<(\s)*/?(?i:script|i|b|u|embed|object|a|frameset|frame|iframe|meta|link|style|table|th|td|tr|tbody|input|select|option|form|map|area|!--)(.|\n)*?>', > '\&\s'); I think you're expecting that the (?i option business will work somewhere other than the start of the pattern. It won't, and it doesn't work in the style you've used it anyway. See the manual: http://www.postgresql.org/docs/8.2/static/functions-matching.html particularly section 9.7.3.4. regards, tom lane