Regular expression in oracle for hyphen


Hello



I want to match a word "{color: #993300} 83 - ASG {color}" using regexp_like and I used ' {color: #993300} ^ 83-* {color}' pattern corresponds to that Word, but it also matches the words like "{color: #993300} 8307-YUF {color}". could someone please tell me which model should I use to match words like {color: #993300} 83 - ASG {color}.



Also, I need to know the similar trend in oracle for the ' {color: #993300} \b {} {color} "used in .net.



Thanks in advance.


Prasad

Use ' ^ 83-. * »

' *' is not generic, it means that it is of the previous character. "." is generic.

No idea about .net.

Tags: Database

Similar Questions

  • Validation using regular expressions or oracle fn

    Hello

    I want to apply validation to a column. I'm trying to see if I can use the regexp_replace function to find a boss and see if I can replace it to a better format. Can someone help me with these rules?

    1. only the characters a - z, A - Z, 0-9, ', - is allowed. If there are no other characters, then these characters must be removed.

    2. name should not begin with a symbol.

    3. If there is any symbol permitted in the name, (for example the hyphen) then the hyphen should be preceded and followed by a space.

    I would like to know if the above can be obtained by regular expressions or any other function will be useful to achieve the same.


    Thank you very much

    Cherkaoui

    HI, Charan,

    Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

    Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.  Post in this case, maybe 5 or 10 strings, and what you would like to see (a string corrected, or a 'yes' / 'No' flag saying if this string follows rules.)

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

    2784427 wrote:

    Hello

    I want to apply validation to a column. I'm trying to see if I can use the regexp_replace function to find a boss and see if I can replace it to a better format. Can someone help me with these rules?

    1. only the characters a - z, A - Z, 0-9, ', - is allowed. If there are no other characters, then these characters must be removed.

    2. name should not begin with a symbol.

    3. If there is any symbol permitted in the name, (for example the hyphen) then the hyphen should be preceded and followed by a space.

    I would like to know if the above can be obtained by regular expressions or any other function will be useful to achieve the same.

    Thank you very much

    Cherkaoui

    Sorry, we don't know what you want to do.

    1 seems to mean you want to change the given string so that it follows the rules.  (What exactly are special characters?  Are there only 2 special characters: single quotation mark and hyphen?)

    2 seems to tell us that you want to check if it meets the rules

    3. can be a

    I'll assume that you want to modify the string so that the returned value corresponds to rules.  This means that if the given string violates, 2 symbols will be removed from the beginning of the string, and if it violates 3, then spaces will be added.

    I don't think that there is a way to do this with a regular expression.

    You can make each with a separate REGEXP_REPLACE corrections, and make all in the same query by one nesting inside each other, like this:

    SELECT REGEXP_REPLACE (REGEXP_REPLACE (REGEXP_REPLACE (: str)))

    , "[^ a-zA-Z0-9 cm-]"

    )

    , '^[''-]+'

    )

    , ' *([''-]) *'

    , ' \1 '

    ) AS new_str

    OF the double

    ;

    of course, I can't test it, until post you some sample data and the exact results you want from these data.

    Here, the inner REGEXP_REPLACE rule 1 applies.  It deletes all characters except a to z small letters, capital letters A to Z, numbers, spaces, single quotes and hyphens.

    Rule 2 applies the REGEXP_REPLACE middle.  It removes the single quotes and hyphens that appear at the beginning of the string.

    The external REGEXP_REPLACE rule 3.  It guarantees that each single quotation mark or a hyphen is preceded and followed by a space.  If there is already a space (or several spaces) before and/or after the special symbol, they are replaced by a single space.  If this isn't what you want, it can be fixed, but it will make the expression even messier.

    You might consider to write a user-defined function to normalize strings.  In a function procedure, you can apply the rules one after the other. you need not nesting complicated like that.  Of course, a user-defined function will be slower, but maybe it's not a problem.

    Still, the above query converts the string so that the production rules.

    If you just want to check whether a string conforms to the rules, you can compare the original string to the output of the above expression.  If they are identical, then the string is in accordance with the rules.

  • Use matching of regular expressions to search for parentheses

    Hi all

    I am currently looking for a particular pattern in a string, I can't display the exact string, but say its something like that.        corresponds to regular_pattern (5000): 0

    I'm also looking for the a different model at the same time, so I have to use the corresponding regular expression and the | function.  I can't understand how to match this model because the regular expression function allows parentheses unless I put them in the legs, and that does not help me for this.

    Any advice?

    Thank you

    Matt

    Have you tried to escape the bracket?

  • Regular expressions in JavaScript for CP5?

    I can't have a regular expression in JavaScript window. First, CP 5 supports regular expressions?

    I'll answer my first question. Yes, he does. For a code example, see:

    http://www.Infosemantics.com.au/Adobe-Captivate-advanced-eLearning-tutorials/report-custom - Captivate-scorm-variables-with-javascript

  • without using regular expressions in oracle 9i

    Hello all;

    I have the following below test data
      insert into p
          (id)
        values
          ('\G1\G2');  
      insert into p
          (id)
        values
          ('\A1\');
       insert into p
          (id)
        values
          ('\B1\B2\B3');
           insert into p
          (id)
        values
          ('\J1\J2\J3\J4');
    and this is the output I want however
    ID
    G1
    null
    B2
    J3
    the result is obtained by looking at the second to the last entry and extract...

    so for \G1\G2, the second to the last entry was G1, therefore, we have G1
    for \A1\ there is no second of the last entry and that is why it is null
    for \B1\B2\B3 the second to the last entry is B2

    user13328581 wrote:

    for \A1\ there is no second of the last entry and that is why it is null

    The entries are separated by------, right? Then id = \A1\ has two inputs A1 and NULL. I'll assume id = \A1. Then:

    with t as (
               select '\G1\G2' id from dual union all
               select '\A1' from dual union all
               select '\B1\B2\B3' from dual union all
               select '\J1\J2\J3\J4' from dual
              )
    -- end of on-the-fly data sample
    select  substr(id,instr(id,'\',-1,2) + 1,instr(id,'\',-1,1) - instr(id,'\',-1,2) - 1) id
      from  t
    /
    
    ID
    ------------
    G1
    
    B2
    J3
    
    SQL> 
    

    SY.

  • regular expression to search for records with only numbers

    Hello

    I need a query to find only numebers. My collar is of type varchar and has values such as
    col1
    --------------------------
    1234456789
    madh144reddy
    123end
    end123

    I need ouput as only numbers EG
    o/p should be
    1234456789

    REGEXP_LIKE (col1, ' [[: digit :]]');]])

    Hello, sorry misunderstood, try:

    WITH test_tab AS (
    SELECT '1234456789' col1 FROM DUAL UNION ALL
    SELECT 'madh144reddy' FROM DUAL UNION ALL
    SELECT '123end' FROM DUAL UNION ALL
    SELECT 'end123' FROM DUAL)
    -- end test data
    SELECT *
      FROM test_tab
     WHERE REGEXP_LIKE(col1,'^[[:digit:]]+$');
    
    COL1
    ------------
    1234456789
    
  • Indexing on search for regular expression for dynamic model

    Hi all

    Is it not possible to create an index for the regular expression search (REGEXP_LIKE) for the model 'dynamic '?

    If the model is static, we can create FBI, but is it possible for dynamic diagrams? Please notify.

    Kind regards
    Hari

    N °
    The best option is an Oracle text index.
    http://download.Oracle.com/docs/CD/E11882_01/text.112/e16594/TOC.htm

  • The regular expression.

    Hello all, I need to learn the normal Oracle database expression. Peut
    anyones tell me where to find information - good sites that give the secrets ;)
    I already look but like some tips. Lydie

    James wrote:
    Hello all, I need to learn the normal Oracle database expression. Peut
    anyones tell me where to find information - good sites that give the secrets ;)
    I already look but like some tips. Lydie

    Hey James,.

    I've been watching this recently myself and I have a little
    my favorite sites. Appreciate the subtleties of the Regex - with any
    luck, you won't even have to learn any PL/SQL ;)

    Good introdution
    http://www.zytrax.com/tech/web/regex.htm
    
    Simple summary of Oracle's regular expressions
    http://www.regular-expressions.info/oracle.html
    
    Not forgetting the Wiki (contains table with vi
    equivalents - for those of us who use a real editor ;)
    http://en.wikipedia.org/wiki/Regular_expression
    
    This site should be one of your main ports of call for any Oracle issues.
    Good forums also - better software than Oracle themselves.
    http://www.orafaq.com/node/2404
    
    Morgan's Library - used to be psoug.org - don't know what happened - anyone?
    Daniel posts here from time to time
    http://www.morganslibrary.org/reference/regexp.html
    
    And,not forgetting the Oracle docco.
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_regexp.htm
    http://docs.oracle.com/cd/B12037_01/appdev.101/b10795/adfns_re.htm
    Also look on OTN for a .pdf for introduction.
    

    HTH,

    Paul...

  • Multiline - Regular Expression Match string

    I'm trying to understand the format of a regular expression to pull select off multi-line string lines and fill in these lines as the individual elements of an array of strings using regular expressions to Match. The total length of the multiline string may vary as well as the text in the string. The string can contain letters, numbers and special characters. I've attached an example VI. In the example of VI, I want to only return lines starting by "device #" in the table. The number of lines starting by "device #" can vary, but I want to capture them all.

    Or is there a better functioning to be used instead of the corresponding regular Expression that will give me the desired result?

    aaronb wrote:

    I'm trying to understand the format of a regular expression to pull select off multi-line string lines and fill in these lines as the individual elements of an array of strings using regular expressions to Match. The total length of the multiline string may vary as well as the text in the string. The string can contain letters, numbers and special characters. I've attached an example VI. In the example of VI, I want to only return lines starting by "device #" in the table. The number of lines starting by "device #" can vary, but I want to capture them all.

    Or is there a better functioning to be used instead of the corresponding regular Expression that will give me the desired result?

    Corresponding regular expression works well for this.

    Ben64

  • Complex regular expressions without multiple passes

    Does anyone know of a tool that can handle more complex regular expressions without chaining of multiple copies of the VI regular expressions?

    For example, if I have a XML string as

    Power supply error has occurred.

    Sorensen SGA166/188

    and I am interested in the tag method to retry only, I could write a regular expression something like

    .*.*

    to parse the string inside the tag.

    kc64 wrote:

    For example, if I have a string like

    My email address is [email protected].  Please no spamming not me.

    and I am interested in the domain name of the email only address, I could write a regular expression something like

    @(\w)*\. (com: net | org)

    to parse the string 'gmail '.

    Forgive me if I am away from base, but I'm flying blind at the moment (not LV to test what I say).  You can add to the power of a regular expression using submatches or capture groups.  The regular expression you wrote will grab (I think) @gmail.com for the entire game.  Let's say you want to get 'gmail' without a second function call.  You can do the first group of a little dishonest selection by moving the * inside the parentheses.  Then, on the BD pull down on the bottom of the function of regular expression matching to expose a variable number of submatches (both should be in this case).  The first should be 'gmail '.   The second one should be "com."

    In summary, @(\w*)\.) (com: net | org) should give you gmail in the first submatch.  Of course, my Perl is a little rusty and LV cannot apply in the same way.

  • Changeparticular the characters of a string using regular expressions...

    Hi all
    I'm writing a function using the function of expression regular oracles REGEXP_REPLACE but I could not succeed until now.

    My problem is as follows, I have a text in a column say "Scott Sdfdfs Sdfd" I want to replace all the s and S with X characters and make the text looks like "XdfXdf XdfdfX Xdfd".

    It is possible by using regular expressions in oracle?
    Can you give me some clue?

    Thank you
    select
      regexp_replace('sdfsdf Sdfdfs Sdfd',
                     's|S', 'X') Replaced
    from dual;
    
    REPLACED
    ------------------
    XdfXdf XdfdfX Xdfd 
    
  • Oracle regular expressions - splits the string into words for

    Hello

    Nice day!

    My requirement is to split the string into words.

    So I need to identify the new line character and the semicolon (;), comma and space like terminator for string entry.

    Please note that I am currently embedded blank and the comma as separator, as shown below.

    Select regexp_substr('test)
    TO
    string in words, "([^, [: blanc:]] +) (', 1, 1) double;"

    How to integrate the semicolons and line break characters in regular expression Oracle?

    Please notify.

    Thanks and greetings

    Sree

    This has nothing to do with REGEXP. Is SQL * more parser does not not a semicolon at the end of the line:

    SQL > select ' testto, mm\;
    ERROR:
    ORA-01756: city not properly finished chain

    SQL >

    Just break the chain:

    SQL > select regexp_substr ('testto, mm\;' |) '
    2 string into words
    3 \w+',1,level ',') of double
    4. connect by level<= regexp_count('testto,mm\;'="" ||="">
    5 string in words
    6      ','\w+')
    7.

    REGEXP_SUBSTR ('TESTTO, MM\;' |') STRINGIN
    --------------------------------------
    Testto
    mm
    string
    in
    Words

    SQL >

    Or modify SQL * more the character of endpoints:

    SQL > set sqlterm.
    SQL > select regexp_substr ('testto, mm\;)
    2 string into words
    3 \w+',1,level ',') of double
    4. connect by level<=>
    5 string in words
    6      ','\w+')
    7.

    REGEXP_SUBSTR ('TESTTO, MM\;) STRINGINTOWO
    --------------------------------------
    Testto
    mm
    string
    in
    Words

    SQL >

    SY.

  • Looking for a good tesxtbook / and or Web site that explains regular expressions

    I need a manual, for about 70 euros or less, which includes an explanation of regular expressions. I picked up a few things from the text of Steve O'Hearn ora 1z0-047 and ora-docs and articles online, but I want to expand a little bit.

    Also if anyone know a good site that may have a little thorough but easy to read (think intermediate user even though I'm not sure I consider myself even that) promenade walk through regular expressions, please see it me.

    Thank you very much.

    Hello

    If you insist on the books, then:

    https://www.safaribooksonline.com/library/view/Oracle-regular-expressions/0596006012/

    http://www.ktipsntricks.com/data/eBooks/Oracle/Oracle%20regular%20expressions.PDF

    Greetings,

    SIM

  • regular expressions for numbers demical in a comma-delimited list


    I have a table that lists the details of the occupation of the sites of a comma-delimited list:

    create table tenure_test)
    number of site_number
    tenure_detail varchar2 (255));

    insert into tenure_test values (1, ' Crown (Other) (0.15 ha), private (555.25 ha)');
    insert into tenure_test values (2, ' private (5.76 ha)');
    insert into tenure_test values (3, ' private (0.18 ha, Crown (3.25 hectares), Indeterminate (Leased) (5.85 ha)');)

    What I want to do is to use a regular expression to calculate the sum only numbers in the tenure_detail column.

    For example, for site_number 1, it would be 0.15 + 555.25 = 555,4

    I also have another regular expression that has just the numbers in a comma-delimited list.

    For site_number 1: 0.15, 555.25

    I tried this:

    Select site_number, tenure_detail, regexp_substr (tenure_detail, "[0-9] + \.") ([0-9] {2}') under the name test1

    of tenure_test;

    but it lists only the first number.

    Hello

    996454 wrote:

    I have a table that lists the details of the occupation of the sites of a comma-delimited list:

    create table tenure_test)
    number of site_number
    tenure_detail varchar2 (255));

    insert into tenure_test values (1, ' Crown (Other) (0.15 ha), private (555.25 ha)');
    insert into tenure_test values (2, ' private (5.76 ha)');
    insert into tenure_test values (3, ' private (0.18 ha, Crown (3.25 hectares), Indeterminate (Leased) (5.85 ha)');)

    What I want to do is to use a regular expression to calculate the sum only numbers in the tenure_detail column.

    For example, for site_number 1, it would be 0.15 + 555.25 = 555,4

    I also have another regular expression that has just the numbers in a comma-delimited list.

    For site_number 1: 0.15, 555.25

    I tried this:

    Select site_number, tenure_detail, regexp_substr (tenure_detail, "[0-9] + \.") ([0-9] {2}') under the name test1

    of tenure_test;

    but it lists only the first number.

    Here's one way:

    SELECT site_number

    SUM (TO_NUMBER (REGEXP_SUBSTR (tenure_detail

    , "\d+\.\d*" - see Note 1

    ) T

    LEVEL

    )

    )

    ), Total

    OF tenure_test

    CONNECT BY LEVEL<= regexp_count="" (="">

    , '\d+\.\d*'

    )

    AND PRIOR site_number = site_number

    AND PRIOR SYS_GUID () IS NOT NULL

    GROUP BY site_number

    ;

    Output:

    TOTAL OF SITE_NUMBER

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

    1 555,4

    2 5.76

    3 9.28

    Note 1: what exactly makes a 'number '?  I'm assuming it's 1 or more digits, followed by a comma, followed by 0 or more numbers.  You can have a slightly different definition; in this case, change the arguments 2nd REGEXP_SUBSTR and REGEXP_COUNT.

    I guess also that site_number is unique.  If not, you will have to change the CONNECT BY and GROUP BY clauses, to refer to something (or a combination of things) which is unique.

    Relational databases are designed for each column of each row contain 1 single piece of information, not a list delimited with a variable number of elements.  It is so basic to the design of database he called the first normal form.  If your first followed table form normal, this query (and many other queries that involve that table) would be much simpler to write, more efficient to run and less likely to have bugs.  See if you can normalize this table.  Any effort that you have to spend now to normalize the table will pay very quickly.

    Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.

    Don't forget to tell what version of Oracle you are using.  I tried the query in Oracle 11.2 above.  You may need to CONNECT BY a little differently in earlier versions, and REGEXP_COUNT will not work in Oracle 10.

  • Regular expression for invalid number

    Hello world

    I use version oracle as follows:

    SQL > select * from v version $;

    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for 32-bit Windows: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

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

    I use a regular expression to replace invalid values in a table.

    I got oracle error 'ORA-01722 invalid number '.

    My query looks like this:

    SELECT DISTINCT

    MRC_KEY,

    PURPOSE_CD,

    RESIDENCE_DESC,

    TO_NUMBER (regexp_replace (ICAP_GEN_MADAPTIVE, "..?")) 0? 0? (\d+) [-.] ((?', '\1')) as ICAP_GEN_MADAPTIVE,

    Of

    MRRC_INT

    I don't know what are invalid values in the table, so I can write regexp accordingly.

    Any guidance is appreciated!

    Thanks in advance

    J

    Hello

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.  View of the code which is not what you want can be useful, but there niot enough by itself.
    See the FAQ forum: https://forums.oracle.com/message/9362002

    Let's look at what you do:

    REGEXP_REPLACE (icap_gen_madaptive

    , '[+. ]' || -exactly 1 of these characters

    '?0?0?' || -up to 2 ' 0 '

    '(\d+)' || -some numbers (it comes to \1)

    '[-.]?'    -0 or 1 of these characters

    , '\1'

    )

    Is it really what you want?  A group of figures don't match, as the patten must start with a sign more, a point or a space.  You want to allow a decimal point at the beginning and at the end, as in "." 9. '?  If there are numbers before and after the decimal point, as in "1.2", you want only the digints before the comma?  You never said what you want, but I'm guessing that these are things that you don't want.

    If the pattern is found, this changes only the schema, so a string like "FU + 123 BAR" more than the model + 9 "" changed to "9" and the resulting string. "" "" FU9BAR"would be passed TO_NUMBER.

    If the pattern is not found, as in "FOO", nothing is changed, and the entire string is passed to TO_NUMBER.

    I suspect you want to use instead of REGEXP_REPLACE REGEXP_SUBSTR, or, if there is stuff to ignore before and/or after the number you want to include in the model, so that REGEXP_REPLACE will be replaced by nothing.

    This looks like a good argument to use the NUMBER of columns to store numbers.

Maybe you are looking for

  • Satellite P300-28th does not start - windows does not load

    I bought Toshiba P300 28th last week. I spent Vista business successfully in Windows XP Professional with provided Toshiba DVD. Update Windows with Windows Update. After 3 days, laptop turns off suddenly, and because Windows does not start, it in fac

  • HP mini 110 1125NR: forgotten bios password

    I forgot my password bios it says system error fatal stopped cnu9453yp7 password check failed when I enter incorrect password three times please help

  • How to replace the turn of office business

    I recently bought a refurbished ENVY 700 series desktop computer, it is in very good condition. Unfortunately, I accidentally fell and the façade of the Tower in case of cracking. I like the design of the box, but I don't want to have a case cracked

  • Error ID: 0x800CCC0D, impossible to send or receive messages in Windows Live Mail account.

    Original title: cannot send or receive messages for the Windows Live account. Please help me solve this problem! Can't send or receive messages for the Windows Live account. The host 'POP3' could not be found. Please check that you have entered the s

  • Question of HP Office Pro L7680 (C8189A)

    Before you start, I tried the steps in troubleshooting the product support page. When I plug in the power cable, in two lights ethernet on solid orange and green ethernet port. The green light on the tip of the power pack is green. When I turn on the