#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0

    Get words from regex data


    Hi,

    i have column in a data base which has a reg expression data. i want to evaluate the expression and get out of the data. Here is an example, in the below values just need to retrieve only (a,b,c). remaning we can ignore

    column1
    --------------------------------------
    "((x.y.z == "a") OR (y.x.z intersects "b,c"))"


    i am using posgres version :9.2
    pls suggest.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    10
    Do you really want to evaluate
    "((x.y.z == "a") OR (y.x.z intersects "b,c"))""

    or do you want to replace x.y.z with a value from a record?

    And of course: why do you have regular expressions instead of SQL statements?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0
    Hi Vinay,

    1. i don't want to replace records to x.y.z, just need a value from the expression which is in Quotes.

    2.if there is sql statement option let me know.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    10
    The problem is that regular expressions are always applied to a string, they are not mathematical equations like "1+2=a" where the output is somehow a=3. Also, the keyword OR and INTERSECT don't exist in regular expressions (at least not for PostgreSQL)

    So, what are you working on, where do these expressions come from?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by Vinny42
    The problem is that regular expressions are always applied to a string, they are not mathematical equations like "1+2=a" where the output is somehow a=3. Also, the keyword OR and INTERSECT don't exist in regular expressions (at least not for PostgreSQL)

    So, what are you working on, where do these expressions come from?
    these expression comes from another table.we are fetching the columns and formatting the data to load into another table.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    158
    Rep Power
    10
    these expression comes from another table.we are fetching the columns and formatting the data to load into another table.
    But this expression, if postgreSQL can evaluate it, will just return false, always. "x.y.z" is not equal to "a" and it has nothing in common with "b,c".

    So perhaps you need to do a bit more explaining about how you think this is supposed to work :-)

IMN logo majestic logo threadwatch logo seochat tools logo