2

I have the atttribute table with the values like these:

'WOLF CLOSE' 'ROBERTSON WAY' 'JEFFREY DRIVE' and so forth...

I would like to get rid of the ', although the regular formula for the replace seems not to work

 regexp_replace("STREET",''','')

Is there any other way to get rid of the apostrophe mark?

3
  • 3
    you'll need to escape the middle ' - I forget what the escape char is for those expressions try \\'
    – Ian Turton
    Commented May 17 at 7:59
  • Why use regexp_replace rather than a simple replace ? anyway in both case you will need to escape the quote by doubling it so use regexp_replace("STREET",'''','') or replace("STREET",'''','')
    – J.R
    Commented May 17 at 9:51
  • 1
    Also note that unless you use a more complex expression in your regex_replace this will also remove legitimate quote if present (ie. it will turn 'O'Hare International Airport' to OHare International Airport)
    – J.R
    Commented May 17 at 10:00

1 Answer 1

4

Use this: replace (STREET, '''','')


Variant: to remove only single quotes ' at the start and end and keep them inside the string (O'Hare International Airport, see comment by @J.R), use:

regexp_replace (STREET,'^''|''$','')

'O'Hare International Airport' -> O'Hare International Airport

In RegEx, ^ stands for start, $ for end of line, see here. The pipe | is a logical OR operator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.