A doubt on REG EXP

Hi friends,

Please specify the doubt in Reg Exp.

Table EMP a sequel EMP_NAMEs:

============
Anand
Bala_G
Chitra
David_C
Elango
Faye
============

We have a set of characters as "abcdefghijklmnopqrstuvwxyz0123456789".

Now we must find EMP_NAMES County, whose characters (any) are not in the list of characters in the list above. In this example, the result should be 2. for example, "Bala_D" and "David_C. The query should be like:

Declare
v_string varchar2 (50): = "abcdefghijklmnopqrstuvwxyz0123456789";
v_count number (6);
Begin
Select count (*)
in v_count
WCP
where regexp_like (emp_name, v_string);

dbms_output.put_line (v_count);

end;

========================

Thanks in advance!

Hello

Welcome to the forum!

To use REGEXP_LIKE, you could say:

WHERE     REGEXP_LIKE ( emp_name
              , '[^abcdefghijklmnopqrstuvwxyz0123456789]'
              )

However, it will be faster not not to use regular expressions:

WHERE   LTRIM ( emp_name
           , 'abcdefghijklmnopqrstuvwxyz0123456789'
           )          IS NOT NULL

Published by: Frank Kulash on 10 October 2012 16:18
Removed the extra single quote, after DAMorgan, below.

Tags: Database

Similar Questions

  • Reg exp query

    I want to separate al chain which are sperated by '-' using reg exp, could you please help me in this

    E WD-MS-HB-ON
    Thanks in advance

    Hello

    There seems to be some typos in response #1; Use the response form #2.

    For example, for the 3rd part the hyphen-delimited, use

    SELECT REGEXP_SUBSTR ('E-WD-MS-HB-ON"

    , ' [^-] +' - note + sign at the end

    1. this argument is always 1

    3. part wanted (1 or greater)

    ) AS part_3

    DOUBLE;

    If you publish no usable sample data, so people can not test their ideas, and makes makes much more likely wrong answers.

  • Reg exp to divide the values of the variables

    Hello all, I use Oracle 11.2 of SOE, the value of the variable C is: numberA:numberB for example, C: = ' 1 B: 5 A: 12 has: B: 43 3A ", I have divided than the values of two Variables A and B with the letters of withdrawal and replacement of: for the comma. Namely, the value of each would be: is: 5,12,43 B is: 1.3 someone could help to come up with the correct Exp Reg for this task. Thanks in advance.

    Here's a way (like SQL or PL/SQL):

    with t (Spercu))
    Select "1 B: 5 A: 12 A: B: 43 3A ' double
    )
    Select Spercu
    , regexp_replace (regexp_replace (regexp_replace(strC||':','\d+B:'),' A:$ '), ':', ',') as strA
    , regexp_replace (regexp_replace (regexp_replace(strC||':','\d+A:'),' B:$ '), 'B:', ',') as strB
    ;

    SPERCU STRA, STRB
    ---------------- -------- ------
    1 B: 5 A: 12 A: B: 43 3A 1.3 5,12,43

    or

    declare
    varA varchar2 (30);
    varB varchar2 (30);
    varC varchar2 (30): = ' 1 B: 5 A: 12 A: B: 43 3A;
    Start
    varA: = regexp_replace (regexp_replace (regexp_replace(varC||':','\d+B:'),' A:$ '), ':', ',');
    varB: = regexp_replace (regexp_replace (regexp_replace(varC||':','\d+A:'),' B:$ '), 'B:', ',');
    dbms_output.put_line (Vara);
    dbms_output.put_line (varB);
    end;
    anonymous block filled
    5,12,43
    1, 3

    Replace it after you add a trailing colon varC, Interior removes all the ' nB: "Vara and all the" nA: "from varB. The Middle replace deletes the pair of colon final letter, and replace external converts the other pairs of commas leter-colon.

    Kind regards
    Bob

  • REG EXP to find if a field starts with a letter

    Hello

    I have a code to clean some phone numbers, and now I want to add a condition to leave the field only if it begins with a letter.

    -------------------------------------------------

    Select

    SR_SERVICE_ID,

    case
    When SR_SERVICE_ID like "% @% ' -does not INCLUDE YEAR ' @' SYMBOL
    then
    SR_SERVICE_ID,
    case
    When SR_SERVICE_ID ' ^ [a-zA-Z] "-STARTS WITH a LETTER (NOT the BODY)"
    then
    SR_SERVICE_ID

    on the other

    '0' || regexp_replace ({SR_SERVICE_ID, ' \D|^0{1} "")-ADD A '0' FOR THE START OF THE FIELD AND GARNISH

    end CLEANSED

    Of
    TABLE_1;

    --------------------------------------------

    The "SR_SERVICE_ID" field contains email addresses, phone numbers and MOBILE numbers in the format '0400123456'

    I want the script to check if the value of the field begins with a letter or contains a ' @' & ignore them and then go to add a '0' in the field at the start.

    Everything works except the below;

    ------------------

    case

    When SR_SERVICE_ID ' ^ [a-zA-Z] "-STARTS WITH a LETTER (NOT the BODY)"

    then

    SR_SERVICE_ID

    ------------------

    The problem is that it does not accept the part of the instruction box on the field starting with a letter?

    Can anyone comment why it won't explain all the parts of the Reg Expression they add so I can learn more?

    Thank you

    Hello

    woof777 wrote:

    Thanks again,

    Can you explain what you mean by "then you must only change this WHEN this CASE expression clause.

    I tried everything I can think of, use the instructions box separately & everything is OK, once I add the second back, "Missing Keyword" error.

    I don't see what went wrong the syntax below is just an example, it is not supposed to be correct, just display synatx method.

    ------------

    "case when (expression) then foo .

    -case when (expression) then Do_Something_More

    Else (expression)

    END New_Field_Name ".

    --------------

    Miss me a rule simple syntax here, everything suggests?

    It seemed all you had to do was change a WHEN clause, but unless you post some examples of data in a form usable (for example, CREATE TABLE and INSERT statements) I can't say for sure.

    CASE expressions don't 'do something', or 'do something' in a CASE expression.   What comes after each key word IS a noun, not a verb.  Like all expressions, a CASE expression is something that generates a unique value in a SQL data types; in this case, a VARCHAR2.  After each THEN or ELSE keyword, there must be an expression of the same type.

    After the key words WHEN you have conditions (i.e. operations that result in TRUE, FALSE, or UNKNOWN), not expressions.

    Thus a better model of a CASE expression

    CASE
        WHEN  condition_1  THEN  expression_1
        WHEN  condition_1  THEN  expression_2
                                          ELSE expression_3
    END
    

    If (but only if) the CASE expression is the last part of a column in a SELECT clause, then it can be followed by an alias, such as New_Field_Name.  The alias is the part of the syntax of the SELECT clause; It's completely outside of and independent of the syntax of the CASE expression.

  • using reg exp

    Hello

    I need to extract the first file name token (and not the directory path) of a string like this:

    D:\MIRACLE\UPLOADS\1361\HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62
    HG-ouA02 #xaldb #alertlog_contents #22022010111941.mirdf.loadfailed_240210095258_62
    \HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62
    /Hg-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62

    the chips would be bed HG-ouA02 in all cases

    Could you help me create a reg expression to get the token?

    Best regards
    Mette

    Hello

    Whenever you have a problem, it helps if you post your sample data in a form, people can use.
    CREATE TABLE and INSERT statements are great. therefore:

    CREATE TABLE     table_x
    AS          select 'D:\MIRACLE\UPLOADS\1361\HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62'
                   AS filename, 1 as x_id FROM dual
    UNION ALL     SELECT 'HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62'
                   AS filename, 2 as x_id FROM dual
    UNION ALL     SELECT '\HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62'
                   AS filename, 3 as x_id FROM dual
    UNION ALL     SELECT '/HG-ORA02#xaldb#alertlog_contents#22022010111941.mirdf.loadfailed_240210095258_62'
                   AS filename, 4 as x_id FROM dual
    ;
    

    It also helps if you explain how you get the results you want from these data.

    Assuming that
    (a) the name of file is divided, firstly, by ' / ' or ' \' characters, and
    (b) each of these parts can be subdivided into tokens by '.' or the characters ' # ' and that
    (c) we want the first part (b) of the last (part a):

    SELECT     REGEXP_SUBSTR ( REGEXP_SUBSTR ( filename
                              , '[^/\]*$'
                              )
                    , '[^.#]+'
                    ) AS token_1
    FROM     table_x;
    

    Here the inner circle REGEXP_SUBSTR finds the last part delimited by / or \. You can add other delimiters by placing them in square parentheses, anywhere after ^.
    The external REGEXP_SUBSTR works on the results of the Interior. He returned the first part bounded by. or #. Again, you can add other delimiters.

  • Question reg exp

    Hello!

    The selection of only printable characters in VARCHAR column?

    Kind regards

    Psmakr
    SQL> SELECT REGEXP_SUBSTR('AS11  sfd' || CHR(7) || 'xx', '[[:print:]]+') FROM dual;
    
    REGEXP_SU
    ---------
    AS11  sfd
    
    SQL>
    
  • Question about reg expression

    Dear all,

    I'm new on reg exp. Could someone give me the reg expression for

    This string.


    000P * 00000000


    where O is digit

    * is an alpha charachers


    the string is therefore 3 numbers, hard coded P and a character alpha and 8

    for example: 123Pa45678981

    OR 223Px00000012


    the length of the shot must be 13 characters, and no more.


    Thank you

    Prash

    Hello

    DPT-Opitz wrote:

    } »

    + matches "1 alphabetic characters or more .

    To match "any 1" only, lose the +:

    } »

  • Reg expressions

    Hi all

    IAM learning reg exp

    I have cases where iam trying to check is that the first letter of the string is of type char, which iam (able to)
    IAM also able to check for the number, but unable to this looping...

    I mean D45GHY iam trying to exract D and 45 but unable to understand how to adapt it in reg exp

    D45GHJI of entry on-site D45
    D4465GHJI of input D4465 on-site
    Entry exit J7 J7GHYT
    entry GHHIT J9 output J9

    logic is that if the first character is the alphabet (A - Z) and second character is number;
    I have to extract to a digital tank is encountered.

    can you please think or pass on some readings...

    Hello

    Try:

    SELECT REGEXP_SUBSTR('D45GHJI', '^[[:alpha:]][[:digit:]]*[^[:alpha:]]') FROM DUAL;
    
    D45
    D4465
    J7
    J9
    
  • Regular expression for the characters of perticular?

    Hello

    I use jdev 11.1.1.7

    I need to validate the input field

    1 length should be 10 characters (alpha neumeric)

    2 first 9 characters are numbers or alphabets. for example: 0123ac456

    3. last character only alpahbet and those are ("A' 'B' 'C', 'H' 'J', 'K', 'L'"S""T""V""X".)

    I write like this: ^ [0-9a - z ABCHJKLSTVX] {10,10} $

    But we must all alphabet in the last takes not mentioned the letters...

    any body can help me...

    Kind regards

    User.

    Try the following reg exp.

    ' ^ [0 - 9a - zA - z] {9,9} [ABCHJKLSTVX] {1,1} $".

    Timo

  • Script request to toggle the visibility of the multiple layers using regex

    Hello

    I did a ton of research, trail / error and need to reach out for help.

    I'm trying to create a PS script that activates / deactivates the visibility of the layers AND groups based on a regular expression in a PS document.

    EXAMPLE GROUP PS & LAYERS STRUCTURE

    =======================================

    • / / example

    • header

    -some layers

    -/ / test

    • footer

    -another layer

    -/ / content area

    Bullet = group

    Hyphen = layer


    This script should hide the two "/ / example", "/ / test ', and ' / / content area ' on track. Ideally, the script would reveal these layers and groups.


    I managed to find two scripts that make each half of the result you want below.

    Part 1: Use of regular expressions to locate each layer and the Group (I changed the reg exp for use cases):

    Re: Script to search for layer names

    by: Michael L Hale

    var re = /-/-/. * / ; corresponds to a reg exp var = collectNamesAM (re); Download the table of correspondence of layer indexes for (var l = 0; l < matches.length; l ++) {makeActiveByIndex (matches [t], false);   do something with layer alert (app.activeDocument.activeLayer.name); } / / next match if no function collectNamesAM (re) {var allLayers = new Array();   var startLoop = number (! hasBackground());   var endLoop = getNumberOfLayer();   for (var l = startLoop; l < endLoop; l ++) {if (! isValidActiveLayer (l)) {l ++;}}   } If (match (re) getLayerNameByIndex (l)! = null) {allLayers.push (l);   allLayers return}}; }; / * / / / / / Function: getActiveLayerIndex / / Description: Gets Gets the index of the Action Manager API / / to activeLayer corrected for background layer / / use: var idx = getActiveLayerIndex();  Entry: No / / Return: number - correct AM itemIndex / / Dependices: hasBackground / / / * / function getActiveLayerIndex() {var Ref = new ActionReference();   ref.putProperty (1349677170, 1232366921);   ref.putEnumerated (1283027488, 1332896878, 1416783732);   var RES = executeActionGet (Ref) .getInteger (1232366921) - number (hasBackground()).   RES IS 4? RES ++: res / / why the skip in this doc?    return res; } / * / / / / / Function: (isValidActiveLayer) / / Description: LayerSection checks for the "real" layers / / use: if (isValidActiveLayer()) / / entry: no / / return: Boolean - True if this is the end of a game / / Notes: not necessary if the layer has been made active / / using the Action Manager API / / / * / function isValidActiveLayer (idx) {var propName = stringIDToTypeID ("layerSection"); / / cannot replace var ref = new ActionReference();}   ref.putProperty (1349677170, propName); TypeID to "Rprp" / / "Lyr", idx ref.putIndex (1283027488, idx); ""   var / / desc = executeActionGet (ref);   type var = desc.getEnumerationValue (propName);   var RES = typeIDToStringID (type);   return res == "layerSectionEnd"? false: true; }; / * / / / / / Function: hasBackground / / Description: bottom layer using AM API Test / / use: if (hasBackground());  Entry: No / / return: Boolean - true if a background layer doc / / Notes: requires that the document be active / / DOM: App.Document.backgroundLayer / / / * / function hasBackground() {var res = undefined;   try {var Ref = new ActionReference();   ref.putProperty (1349677170, 1315774496);   ref.putIndex (1283027488, 0);   executeActionGet (ref) .getString (1315774496);   RES = true;   } catch (e) {res = false} return res; }; function makeActiveByIndex (idx, forceVisible) {try {var desc = new ActionDescriptor();}   Var ref = new ActionReference();   ref.putIndex (charIDToTypeID ("Lyr"), idx) desc.putReference (charIDToTypeID ("null"), ref);   desc.putBoolean (charIDToTypeID ("MKV"), forceVisible);   executeAction (charIDToTypeID ("TPCV"), desc, DialogModes.NO);   } catch (e) {return-1 ;}} ; function getNumberOfLayer() {var Ref = new ActionReference();   ref.putEnumerated (charIDToTypeID ("Dcmn"), charIDToTypeID ("Ordn"), charIDToTypeID ("Trgt"));   var / / desc = executeActionGet (ref);   var numberOfLayer = desc.getInteger (charIDToTypeID ("NmbL"));   Return numberOfLayer; }; function getLayerNameByIndex (idx) {var Ref = new ActionReference();   ref.putProperty (charIDToTypeID ("Rprp"), charIDToTypeID ("Nm"));   ref.putIndex (charIDToTypeID ("Lyr"), idx);   Return executeActionGet (Ref) .getString (charIDToTypeID ("Nm")) ;} ;

    This script shows an alert for each layer / group name that corresponds to-is to find the layers / groups!

    Now I need the layers / groups to simultaneously show or hide depending on their status.


    I found a script that toggles the visibility of a specific name (in this case "GRID") here:

    Photoshop-grid-enable/disable/turn Grid.jsx to master · squarefrog/photoshop-grid-toggle · GitHub

    var gridName = "GRID"; Implement what you call your grid layer together. function toggleGridLayer() {if (app.documents.length > 0) {var gridLayer = app.activeDocument.layerSets.getByName (gridName);}}         gridLayer.visible =! gridLayer.visible;     toggleGridLayer()}};

    Essentially, I want to merge the tilting head of visibility script in the script of the regular expression. Any help would be great. Thanks in advance!


    Note: The use of CC PS 2015

    This script is all on one line and hard to see where are the separate lines. If you want the code to turn on or off a layer, you can use:

    var docLayer = app.activeDocument.activeLayer;
    docLayer.visible=docLayer.visible==false;
    
  • An alphanumeric string

    Good day to all,

    I have what I hope to be a simple question. I have a table that I'm storing Latitude and longitude in. The current format for each example is N432301 for the Latitude and
    W0844150 for Longitude.

    I need the output formatted to

    N 43-23-01 for Latitude

    and

    W-84-41-50 of Longitude.

    GMoney says:

    Greg,

    I ran this by using the following:

    {code}

    with xx (lat select 'N402456', 'W1203926' double lon)

    Select substr (lat, 1, 1) | '-' || substr (lat, 2, 2) | '-' || substr (lat, 4, 2) | '-' || substr(lat,6,2) latitude,

    substr (Lon, 1, 1) | '-' || substr (Lon, 3, 2) | '-' || substr (Lon, 5, 2) | '-' || longitude substr (Lon, 7, 2)

    XX.

    {code}

    and the result was:

    LATITUDE LONGITUDE
    N 40-24-56 W 20-39-26

    which is false, because in this case the lon was 3 Tank 2 after abandoning the '0' of the 084.

    That's why I started with "Really need rules to ensure that it is accurate"

    Seriously, if you don't give us some good features, you can't complain that much if we get not all your requirements in the first inning.

    If you find a first 3 digits, no problem...

           substr(lon,1,1) || '-' || substr(lon,2,3) || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
    

    If you need to drop the 0 on the previous example (still guessing, because you have not given any real rules)

           substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
    

    but at this point, Mike reg exp's scheming probably work better

    Laughing out loud

    [edit]

    Just for completeness:

    with xx as ( select 'N432301' lat, 'W0844150' lon from dual union all
                 select 'N402456'    , 'W1203926'      from dual
     )
    select substr(lat,1,1) || '-' || substr(lat,2,2) || '-' || substr(lat,4,2) || '-' || substr(lat,6,2) latitude,
           substr(lon,1,1) || '-' || to_char(to_number(substr(lon,2,3)),'fm999') || '-' || substr(lon,5,2) || '-' || substr(lon,7,2) longitude
      from xx;
    

    LATITUDE LONGITUDE

    ---------- ------------

    N 43-23-01 W - 84 - 41 - 50

    N 40-24-56 W - 120 - 39 - 26

    2 selected lines.

    Great demands, comes with excellent results.

    Bad conditions, just mediocre results

  • Concatenate zero in middle of string after each comma

    Hi all

    I have it here is the input string

    '1804','1805','1826','1827','1944','3554','3557','3558','3562','3565'

    and need for o/p as

    '18004','18005','18026','18027','19044','35054','35057','35058','35062','35065'

    Therefore, the requirement must concatenate to zero after every second character in each comma. I have the 10g version.

    Thank you.

    HI Blushadow,

    your solution worked, thanks for your response, I'm new on reg exp, can u explain (, | ^) this part.

  • Regular expression matches the string starts by &amp;

    Hello

    I'm writing a Reg Exp, which removes all string starts by '&' and ends by '; '. In other words, I am trying to remove something similar to:
     & nbsp;  & quot; & lt; & gt;  
    Any help please.
    It does not work:
    select regexp_replace (ename, ' ^ & [a - z] {2,4} [;] $') of PGE;
    Kind regards
    Fateh

    Like this?

    SQL> with t as
      2  (
      3  select 'xyz & nbsp; test' str from dual
      4  )
      5  select regexp_replace(str,'&.*?;') str
      6  from t
      7  /
    
    STR
    ---------
    xyz  test
    
  • the simple regular expression problem

    Hello

    I need assistance with regular expressions. I have a situation when I need to get data from one table to the other and I think that my problem can be solved using REG EXP, but I don't know how to use them properly.


    I need to separate fileld varchar2 which is basically number/number in 2 separate number fields
     
    
    
    CREATE TABLE tst (CODE VARCHAR2(10)); 
    
    INSERT INTO tst VALUES('10/15'); 
    INSERT INTO tst VALUES('13/12'); 
    INSERT INTO tst VALUES('30'); 
    INSERT INTO tst VALUES('15'); 
    
    CREATE TABLE tst2 (po NUMBER, co NUMBER); 
    I need to get the code in the co and po columns. I think the result should look something like this, but:
     
    
    INSERT INTO tst2 
    SELECT regexp_substr(CODE 'something here to get the number before /') AS po, 
           regexpr_substr(CODE 'something here to get number after') AS co 
    FROM tst;   
    Any help appreciated

    Agree with the above,

    However, if you really want to know how to do with regular expressions you can do it like this...

    SQL> select regexp_substr('10/15','[^/]+',1,1) from dual;
    
    RE
    --
    10
    
    SQL> select regexp_substr('10/15','[^/]+',1,2) from dual;
    
    RE
    --
    15
    
  • One for the era: how to get this output using REGULAR EXPRESSIONS?

    How to get the bottom of output using REGULAR EXPRESSIONS?
    SQL> ed
    Wrote file afiedt.buf
    
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    
    Table created.
    
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    
    1 row created.
    
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    
    1 row created.
    
    SQL> SELECT * FROM cus___addresses;
    
    FULL_ADDRESS
    ----------------------------------------------------------------------------------------------------
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.
    Published by: user12240205 on June 18, 2012 03:19
    /* Formatted on 2012/06/18 17:25 (Formatter Plus v4.8.8) */
    SELECT REGEXP_SUBSTR ((REGEXP_SUBSTR (full_address, '[^,]+', 1, 4)), '[[:digit:]]+') RESULT
      FROM cus___addresses
    

Maybe you are looking for

  • How may e-mail can send list a group?

    Is there a limit to how many people can be on a group email list?

  • Can't see the apps in iTunes

    Hello Need help please. When I connect my iPhone to iTunes and I'm going to 'Apps', I can't see and organize apps on my phone. Only the options I have by clicking on the different screens and drag apps to move. I would like to be able to sort them by

  • on widi on dv6 1152tx

    my laptop "HP pavilion dv6 1152TX" has a direct WiFi?I am running Windows 8 32-bit...Please help me... can I connect it to my phone and television?

  • Active Desktop Recovery appears all night - does not disappear.

    Sometimes my computer switches to Active Desktop recovery, usually at night.  It asks if I want to stop the execution of scripts, but no matter if I answer 'Yes' or 'No' - nothing happens.  Sometimes I can fix by changing my desktop picture or screen

  • Desktop Windows 7 disconnects Internet after going sleep

    Need help. My office disconnects internet connection on another every second or third time base when he falls asleep. Sometimes I can reconnect suite Microsoft connect steps, other no times, no luck. When the icon on the bottom toolbar to connect is