Regular Expressions Query!! -- Help

Hi,
I'm writing a SQL query using Regualar Expressions in Oracle 10g.
select entry_id,entry_value, from entry_logbook where REGEXP_LIKE(entry_value,'^[a-z]|[0-9]|[A-Z]')
I expect the result contains only records with values starting with alphabets or integers.
But I'm getting values like '** Something **', '#123445' etc.
Please let me know what I'm missing here.
Regards,
Venkat

SQL> with sample as
  2  (select '##@Sarma123%$%$' col from dual
  3  union all
  4  select 'sarma' from dual
  5  union all
  6  select '123SARMA' from dual
  7  union all
  8  select 'RADHA' from dual
  9  )
10  select col
11  from sample
12  where regexp_like (col, '^[a-z0-9A-Z]')
13  /
COL
sarma
123SARMA
RADHA
SQL>Cheers
Sarma.

Similar Messages

  • Regular Expression query help.

    Hi, your help will be appreciated,
    I need to replace the a string's pattern with some special characters.
                            Input String := 'mytext*% align="quot;leftquot;><font face="quot;Arialquot;"> *% align="quot;leftquot;"><this is text><p this to replace >'
                            Output String := 'mytext@ align="quot;leftquot;$<font face="quot;Arialquot;"> @ align="quot;leftquot;"$<this is text><p this to replace >'
    Replacing Rules:
    1)              '*%'             should be replaced by '@'
    2)              '>'            should be replaced by $ (only the EVERY FIRST occurrence after the character @ )
    Tried with REGEXP but looks like need your help!
    Thx
    DJ.

    Hi, DJ,
    DeeJay wrote:
    Perfect Frank. Thanks for your help.
    Could you please explain how it is working? you know, these Regexps are hurdle for me always in understanding.Not just you; regular expression can be very cryptic.
    We're saying "replace '*%x>' with '@x$', where x is 0 or more characters from the set of all characters except '>'.
    {code}
    SELECT     REGEXP_REPLACE ( 'mytext*% align="quot;leftquot;> *% align="quot;leftquot;"><this is text>'
              , '\*'     || -- aserisk (special character, must be escaped)
              '%'     || -- percent sign
                   '('     || -- begin \1 definition
                   '['     || -- begin set definition
                   '^' || -- "The set consiting of all characters EXCEPT ...
                   '>' || --     ... the greater-than sign"
                   ']'     || -- end set definition
                   '*'     || -- 0 or more characters from the preceding set
                   ')'     || -- end \1 definition
                   '>'     -- greater-than sign
              , '@\1$'
              )     AS txt
    FROM     dual;

  • Question about Regular Expressions, please help!

    I have created an app which reads files and extracts certain data using regular expressions in JDK1.4 using Pattern and Matcher classes.
    However it needs to run on JDK1.2.2 (dont ask). The regular expression classes are not available in 1.2.2 (the Pattern and Matcher class) so i am looking for something similiar which i can use?
    I need something that loops through all the matches found in the file like how Matcher works i.e.
    while (matcher.find())
    // do this
    Help!

    http://jakarta.apache.org/regexp/

  • Regular Expressions, please help.

    Hello everyone.
    Can I get a Java Regular Expression to match with a word of the following language...
    Start --> Expression;
    Expression --> [0-9]+;
    Expression --> Expression * Expression;
    So the regexp should match with words like:
    4;
    4664;
    4 * 763;
    5 * 4534 * 23534;
    04 * 002 * 1 * 10 * ...
    I would be very happy, if anyone could help.

    I dont think that I need to learn anything more.
    I am sure it is not possible to make, what I want.
    I want to build a compiler.
    I just finished the abstract syntax of my language. Now I need a possibility to compile the concrete syntax of my language to the abstract one.
    But I think, it is not possible with regular expressions.
    Cause I need possibility to match a syntax of type chomsky 2.
    I think regular expressions only match chomsky 3 languages.
    But the "Backtracking"-mechanism of Java RegExp could do this.
    I am not sure with this.
    If you have any ideas please post.

  • Quick regular expression question/help

    Can someone help me with two regular expressions I need. I could spend a while trying to figure it out myself, however times short and I really would like to get a fool proof optimal solution (my attempt would be buggy).
    Sample sentence
    The population, is projected to reach 200,000, or more (by 2020).[7] This is {dummy} text.
    The first regular expression
    I need all brackets and every thing between them to be removed from a sentence.
    Brackets such as: ( ), [ ] and { } .
    I.e. Given the above sentence the following would be returned:
    The population, is projected to reach 200,000, or more. This is text.
    The second regular expression
    If a word has a trailing comma character I need to add a whitespace between the word and the comma.
    I.e. Given the sentence returned from the first regular expression, this regex would return:
    The population *,* is projected to reach 200,000 *,* or more. This is text.
    Many thanks to anyonewho can help me with this!
    Edited by: Myles on Jan 18, 2008 8:12 AM

    http://java.sun.com/docs/books/tutorial/extra/regex/index.html
    http://www.regular-expressions.info

  • Stripping HTML thru regular expression(pls help)

    Hi all..
    I've been trying to use the regular OROMatcher-1.1 expression package downloaded from apache.org.
    it works well with my program but i m having problems building correct regular expression to strip off HTML tags.
    can any of u help me build an expression tha strips of ALL html tags including those with funny spaces such as:
    <a href = "www.here.com">click me</a>
    do help pls. i've tried for ages and its driving me mad

    Hi,
    Wont go into much details but the simplest way to do that would be using XML technology. Try using SAX or DOX whatever you feel comfortable with. I think SAX would be a better choice. For details visit
    http://java.sun.com/xml/?frontpage-spotlight
    /khurram

  • Java Regular Expression Need Help

    I want regular Expression that accept all numbers and it should skip the numbers if it comes in {}

    No this is not workingThen you need to be MUCH clearer as to exactly what you are trying to acheive...
    We aren't mind readers... try posting the string you are parsing and the exact result that you want to get

  • Regular expression (regex) help!

    I am trying to write a correct regular expression but am having difficulties.
    I have a webpage saved as a string and want to extract all the links (urls) from the webpage string.
    The trouble I am having is that some websites surround links using double quotes " " and some use single quotes ' ' around links in html:
    Double quotes around url:
    <a href="www.example.com"></a>
    And single quotes:
    <a href="www.example.com"></a>
    So far I have a regex which extract links if they are surrounded with double quotes (see below), however if a page uses single quotes it screws up ;)
    Pattern.compile("<a\\s+href\\s*=\\s*\"?(.*?)[\"|>]",  Pattern.CASE_INSENSITIVE);So is there a way to say look for double quotes OR single quotes?
    Many thanks
    null

    There's no need to escape the single-quote (or apostrophe) in a regex. The only reason it was necessary to escape the double-quote (or quotation mark) is because the regex was written in the form of a String literal. Neither the single-quote or the double-quote has any special meaning in regexes.

  • Query help in regular expression Query

    Hi all,
    Version details
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - ProductionI have table RULE with one column as CLOB data type and my requirement is as follows
    Sample Data :
    0-7IfFlowControl0.-7dd670afb-2d41-440f-958d-c19f0f75e91dareErrorsPostedAtHeader(00760)ClaimErrorCollection0.-7-1000FlowControl0-8ThenFlowControl0.-8a0c1c903-0c04-4d68-b5a8-10cbd4a03e9faddRequiredElementErrors(00760 & D)
    Expected Output .
    00760
    00760
    D
    I want the values within braces() and when ever there is an & symbol inside braces then i want it in the next row.
    Please see the above example .Any help in this regard is would be highly appreciated ...........
    Thanks,
    P Prakash
    Edited by: prakash on Nov 10, 2011 9:19 PM

    with t
    as
    select '0-7IfFlowControl0.-7dd670afb-2d41-440f-958d-c19f0f75e91dareErrorsPostedAtHeader(00760)ClaimErrorCollection0.-7-1000FlowControl0-8ThenFlowControl0.-8a0c1c903-0c04-4d68-b5a8-10cbd4a03e9faddRequiredElementErrors(00760 & D)' str
      from dual
    ), t1
    as
    select replace(replace(regexp_substr(str, '\([^)]*\)', 1, level),')'), '(') str
      from t
    connect by level <= regexp_count(str, '\([^)]*\)')
    select regexp_substr(str, '[^&]+', 1, t2.l)
      from t1
    cross join
             select level l
               from (
                      select max(length(regexp_replace(str, '[^&]')))+1 cnt
                        from t1
            connect by level <= cnt
           ) t2
    where regexp_substr(str, '[^&]+', 1, t2.l) is not null

  • Regular Expression query

    We will have below data in one column
    ++77++
    ++34_
    --9--
    98
    999
    +00_
    My requirement is to fetch only number from above data. please find output i want from each data
    ++77++ -> 77
    ++34_ -> 34
    --9-- -> 9
    98 -> 98
    999      -> 999
    +00_     -> 00
    Please provide the query for the same.
    Thanks

    Works on 10g or higher:
    with data as
      select '++77++' col from dual union all
      select '++34_' col from dual union all
      select '--9--' col from dual union all
      select '98' col from dual union all
      select '999' col from dual union all
      select '+00_' col from dual
    select col, regexp_substr(col, '[[:digit:]]+') col
      from data;
    COL    COL   
    ++77++ 77    
    ++34_  34    
    --9--  9     
    98     98    
    999    999   
    +00_   00   

  • Regular Expression Query for SQL

    Hi,
    I am working on SQL server and there is a requirement of separating street name and street number. 
    I tried using regexp_substr but not able to do it perfectly.
    Here are some sample names which need cleansing
    Full name 
    street name
    street no
    Bahnhofplatz 1 / Werkstatt
    Bahnhofplatz
    1 / Werkstatt
    Reinacherstr. 149/151
    Reinacherstr.
    149/151
    Kosuth UCA 7/A
    Kosuth UCA
    7/A
    Route des Jeunes 9 / 6 ème
    Route des Jeunes
    9 / 6 ème
    L'Arcadie / Route de Moudon
    L'Arcadie / Route de Moudon
    null
    Hofstetten 206
    Hofstetten
    206
    Rgds
    Amitabh

    try this
    DECLARE @test TABLE (address VARCHAR(50))
    INSERT INTO @test values ('Bahnhofplatz 1 / Werkstatt')
    ,('Reinacherstr.149 / 151')
    ,('Kosuth UCA 7 / A')
    ,('Moudon')
    ,('L''Arcadie / Route de')
    SELECT
    Address,
    CASE
    WHEN patindex('%[0-9]%',address) = 0 then address else substring(address,0,patindex('%[0-9]%',address)) end col1,
    CASE WHEN patindex('%[0-9]%',address) >0 then SUBSTRING(address,patindex('%[0-9]%',address),LEN(address)) end col2
    from @test
    Address col1
    col2
    Bahnhofplatz 1 / Werkstatt
    Bahnhofplatz 1 / Werkstatt
    Reinacherstr.149 / 151
    Reinacherstr. 149 / 151
    Kosuth UCA 7 / A
    Kosuth UCA 7 / A
    Moudon Moudon
    NULL
    L'Arcadie / Route de
    L'Arcadie / Route de
    NULL
    --Prashanth

  • Help in query using regular expression

    HI,
    I need a help to get the below output using regular expression query. Please help me.
    SELECT REGEXP_SUBSTR ('PWRPKG(P/W+P/L+CC)', '[^+]+', 1, lvl) val, lvl
    FROM DUAL,(SELECT LEVEL lvl FROM DUAL
    CONNECT BY LEVEL <=(SELECT MAX ( LENGTH ('PWRPKG(P/W+P/L+CC)') - LENGTH (REPLACE ('PWRPKG(P/W+P/L+CC)','+',NULL))+ 1) FROM DUAL));
    I need the output as
    correct result:
    ==============
    val lvl
    P/W 1
    P/L 2
    CC 3
    But i tried the above it is not coming the above result. Please help me where i did a mistake.
    Thanks in advance

    Frank gave you a solution in your other thread. You could simplify it if you are on 11g:
    SQL> select * from table_x
      2  /
    TXT
    TECHPKG(INTELLI CC+FRT SONAR)
    PWRPKG(P/W+P/L+CC)
    select  txt,
            regexp_substr(
                          txt,
                          '(.*\()*([^+)]+)',
                          1,
                          column_value,
                          null,
                          2
                         ) element,
            column_value element_number
      from  table_x,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= regexp_count(txt,'\+') + 1
                       as sys.OdciNumberList
      order by rowid,
               column_value
    TXT                                      ELEMENT    ELEMENT_NUMBER
    TECHPKG(INTELLI CC+FRT SONAR)            INTELLI CC              1
    TECHPKG(INTELLI CC+FRT SONAR)            FRT SONAR               2
    PWRPKG(P/W+P/L+CC)                       P/W                     1
    PWRPKG(P/W+P/L+CC)                       P/L                     2
    PWRPKG(P/W+P/L+CC)                       CC                      3
    SQL>  SY.

  • Regular expression to substring

    Hi Folks;
    I need to extract dynamically substrings from an attribut A.
    The varchar2 attribut A is defined like that : "LXXXXX/111111(+),LXXXXX/111111(-),LXXXXXX/111111,etc..." Always the same serie.
    I need to store all "111111(+)" "111111(-)" "111111" of the same record in a new attribut named B.
    I feel the regular expressions could help me but i'm not a very good...
    Thanks for your help . ^^

    Try this,
    SELECT LTRIM (REGEXP_SUBSTR (attrA,
                                 '/[^,]+',
                                 1,
                                 LEVEL),'/')
      FROM T
    CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE ( attrA, '[^/]'))
    Example
    SQL> WITH T AS (SELECT 'LXXXXX/111111(+),LXXXXX/111111(-),LXXXXXX/111111,' attrA FROM DUAL)
      2  SELECT LTRIM (REGEXP_SUBSTR (attrA,
      3                               '/[^,]+',
      4                               1,
      5                               LEVEL),'/') exprssn
      6    FROM T
      7  CONNECT BY LEVEL <= LENGTH (REGEXP_REPLACE ( attrA, '[^/]'));
    EXPRSSN
    111111(+)
    111111(-)
    111111
    SQL> G.

  • Regular expression usage question

    Hi there.
    I have a 200 bytes EBCDIC variable record which I need to break down into fields. Fields are positional and are either text, binary numbers, packed-decimal and 64bytes long numbers.
    My question is. Can regular expression handle this complex data.
    I want to isolate each field into their corresponding format. EBCDIC into ASCII text, binary into java Integer and so on.
    The reason for using reqular expression is because the record format could change and regular expression would be easier to modify without having to change the code.
    Your words of advice are highly appreciated.
    Please advice.
    Regards,
    Ulises

    Regular expressions? I don't think so.
    If you have a situation where positions 1-3 might be a binary number like client number, and the format might change so it moves to positions 12-14, then you could certainly write a record-format class to encapsulate that sort of information. In fact that would be a very good idea. But I can't imagine how a regular expression would help in getting a number out of three bytes, for example.

  • Query help in regular expression

    Hi all,
    SELECT * FROM emp11
    WHERE INSTR(ENAME,'A',1,2) >0;
    Please let me know the equivalent query using regular expressions.
    i have tried this after going through oracle regular expressions documentation.
    SELECT * FROM emp11
    WHERE regexp_LIKE(ename,'A{2}')
    Any help in this regard would be highly appreciated .
       Thanks,
    P Prakash

    please go here
    Introduction to regular expressions ...
    Thanks,
    P Prakash

Maybe you are looking for

  • JSP applet tag X Html applet tag (what is the difference?)

    what is the advantage in using the JSP applet tag instead of a simple Html applet tag ? second question: I have an applet in a Html frame, and a menu on the left side.... When the user select the applet option at first time, everything runs ok.. afte

  • Hide lead column in forcasting tab

    Hi friends We are working in a support project. We need to hide one of the lead column (fiscal year) in the forcasting tab in CRM. I kw it can be done in Excel format. But our requirement is to hide the column in the forcasting tab. Is there any way

  • Can I set skip=1 in control file?

    Below is my control file, how can I modify it to skip the first row in my datafile? (the first row is the column header row), I have read some related posts, couldn't find the fix, please help LOAD DATA INFILE 'class.data' BADFILE 'class.bad' DISCARD

  • How to transfer photos between albums?

    I am a new user, I loaded many old photos and want to move them into smaller albums,

  • Reading 'changes' from retroChangeLog in 5.2

    The ldapsearch command in older version (5.1) of Directory Server used to allow the '-o' option to read the 'changes' attribute from a changeLog in a readable text format. However, the same option does not seem to work with version 5.2 - any ideas on