Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2010
    Posts
    64

    Question Unanswered: escaping ' in regular expression

    Hi,

    I ma tryling to escape the special char single quote ( ' ) by using the escape char backslash (\) but it is not working. I might be missing something.

    PFA the command :-
    regexp_like(Column_A, '[^a-z[:space:]\']', 'i')
    OR
    regexp_like(Column_A, '[^a-z[:space:][\']]', 'i')

    My Output should not report cases like :-
    O'Connor
    O'Connell
    O'Keefe

    Please advise

    Thanks and regards,
    Subhotech

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    Hi,

    the problem is not in the single quote into regular expression pattern, but in its putting into string literal representing it.

    Most commonly, it is achievable by doubling it:
    Code:
    regexp_like(Column_A, '[^a-z[:space:]'']', 'i')
    In Oracle 10g and higher, you may also use special quoting mechanism:
    Code:
    regexp_like(Column_A, q'#[^a-z[:space:]']#', 'i')

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    single quote mark is same as CHR(39)
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •