Reg expression

can somebody tell me how to write a query using regular expression instr function to find any alpha character in a string except + - .
i have a varchar field that can contain any of the following values
234, 345.32, -66.33, +32.
if the value enter is 34a or +455.44v then i want to search for alpha character except the . and + sign. so i will searching for v or a.

Something like this?
WITH t AS (SELECT '234' col1
            FROM dual
           UNION
          SELECT '345.32'
            FROM dual
           UNION
          SELECT '-66.33'
            FROM dual
           UNION
          SELECT '+32.'
            FROM dual
           UNION
          SELECT '34a'
            FROM dual
           UNION
          SELECT '+455.44v'
            FROM dual
SELECT t.col1
     , REGEXP_REPLACE(t.col1, '^[+-]|\.[0-9]+|[0-9]+(\.[0-9]*)?', '')
  FROM t
WHERE NOT REGEXP_LIKE(t.col1, '^[+-]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)$') 
;                       C.

Similar Messages

  • Validate through Reg Expression

    Hi,
    I have following requirement to be achieved through reg expressions.
    Need to write a boolean method which takes a String parameter that should satisfy following conditions.
    o 20 character length string.
    o First 9 characters will be a number
    o Next 2 characters will be alphabets
    o Next 2 characters will be a number.(1 to 31 or 99)
    o Next 1 character will be an alphabet
    o Last 6 characters will be a number.
    JDev 11.1.1.6.0

    Hi,
    Hope following links are useful
    https://blogs.oracle.com/shay/entry/regular_expression_validation
    http://www.vogella.com/articles/JavaRegularExpressions/article.html

  • CFINPUT Reg Expression Validation Pattern Help

    I've got a form with a non-required field that needs to meet
    some validation requirements (Numbers, Letters, 'space character'
    or 'blank, empty string' only) if the user chooses to fill it
    out...
    I'm using CFINPUT tag with the following settings, does my
    Reg Expression pattern look OK?
    REQUIRED="No"
    VALIDATE="regular_expression"
    PATTERN="^[a-zA-Z *]{1,40}$"
    MAXLENGTH="40"
    Thanks for any help. I'm v. new to regular expressions (10
    hrs education at Google Univ.)
    Sincerely,
    Paul Cross

    I think you want something more like this:
    ^[a-zA-Z0-9 ]{0,40}$

  • Reg expression help

    Can/will you help me make a regular expression for these characters? I want to replace eveyone occurance in a string contianing these chars
    \/:*"<>|
    with
    right now I am doing a string.replaceAll(...) on each char but I was wanting to combine that to one reg expression. What cha got? I am doing this b/c I am generating file names and those are not valid chars allowed in file names.
    Thanks
    Doopterus

      String regex = "[*<>/'\"\\\\]";In a character class (i.e., between the square brackets), "|" has no special meaning.

  • Seemingly simple, yet annoying reg. expression issue

    Hey guys,
    Im considerably familiar with the use of regular expressions in Java (and other languages), yet seem to be having a very simple problem.
    I wish to match a full stop character occuring after a space in a string, once that space does not occur after a digit.
    e.g. "went to the shop . This is another sentence"
    The code I'm using is this:
    String s = "went to the shop. This is another sentence"
    s = s.replaceAll("([^0-9]+)\\s+\\.","$1.");This doesn't seem to work, neither does:
    String s = "went to the shop. This is another sentence"
    s = s.replaceAll("(\\D+)\\s+\\.","$1.");It seems that there's a problem with the first + symbol, but I'm not sure exactly what the problem is.
    Any insights?
    Edited by: SuperGrover on Jan 19, 2009 12:35 PM

    SuperGrover wrote:
    The problem seems to occur when there's more than one occurance of the space before a fullstop in the string, so the above code doesn't work for the following string:
    "went to the shop . This is another sentence . And another"
    It only replaces the final occurance, despite using the replaceAll method.When I tested your pattern (using JRET), it matched both occurrences in the sample string!
    The matching was done by repeated invocations of the method [Matcher.find|http://java.sun.com/javase/6/docs/api/java/util/regex/Matcher.html#find()].
    Maybe [String.replaceAll|http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)] does something different internally?
    Anyway, are you aware that your expression always matches the entire string preceding the space and the dot?
    This is probably not really what you are looking for. You may want to try this expression instead, which uses negative lookbehind:
    (?<!\d)\s+\.Edited by: McNepp on 20.01.2009 09:47

  • Reg Expression in af:validateRegEx

    Since I can't use my custom validator class (See post Custom validator closes dialog on failure I am trying to use the same regular expression in an <af:validateRegExp> on an <af:inputText>.
    I have tested my regular expression in a completely separate tester that I wrote and it works for every test case I throw at it.
    I put the regular expression inside my custom validator class and it works as expected as well, but I can't use it for above posted reasons.
    So now I've put the regular expression in my backing bean as a private attribute and created a getter method for it. In the validationRegExp component, I used an EL expression to point to the attribute in my backing bean. When I run and put in the same test values, they fail validation.
    The documenation for the validateRegExp says it uses java regular expression syntax, so I shouldn't have to change the regex between the custom validator and the validator component.
    Any ideas?
    Al

    What doesn't work:
    Every success test value that I put in the input text box fails validation. Or maybe I should say that every value I put in the input text box fails validation, although one would expect the failure test value to fail validation, so obviously the issue is that a valid success test value fails validation using the <af:validateRegEx> component with the same regex used in the custom validation class where the same input passes validation.
    What is the issue I see:
    That success test values fail validation using the <af:validateRegEx> component.
    Implentation:
    <af:popup id="resetPasswordPopup"
              binding="#{pageFlowScope.backing_Bean.resetPasswordPopup}">
    <af:dialog id="resetPasswordDialog" type="none"
               title="Reset Password">
    <af:panelGroupLayout layout="vertical">
    <af:outputText value="Enter temporary password for user:"/>
    <af:spacer width="10" height="10"/>
    <af:inputText label="Temporary Password"
                  value="#{pageFlowScope.backing_Bean.temporaryPassword}"
                  required="true">
    <af:validateRegExp pattern="#{pageFlowScope.backing_Bean.passwordRegEx}"
                       hint="Password should be ...."/>
    <!--<f:validator validatorId="passwordValidator"/>-->
    </af:inputText>
    </af:panelGroupLayout>
    <f:facet name="buttonBar">
    <af:panelGroupLayout layout="horizontal" halign="center">
    <af:commandButton text="Yes"
                      action="resetUserPassword"
                      partialSubmit="true"/>
    <af:spacer width="10" height="10"/>
    <af:commandButton text="No" immediate="true">
    <af:returnActionListener/>
    </af:commandButton>
    </af:panelGroupLayout>
    </f:facet>
    </af:dialog>
    </af:popup>

  • Email Reg Expression

    dear all :
    i am using ADF 10 with WLS 11
    i am using the following regular expression for email account :
    <af:validateRegExp pattern="^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$" id="nr3hj" messageDetailNoMatch="#{viewBundle.PleaseInsertValidEmail}"/> and it work fine .
    but i need to force the end user to add the email as the following
    [email protected]
    her i can add ABC@yahoo without (.) dot ,
    so how i can force the end user to add (.) dot in his email like .com , .net , .etc .
    Best Regards

    bara,
    Try [url http://tinyurl.com/lfugwr]this link
    John

  • Help with Reg Expression Start method

    Hi there,
    I've been looking through some examples of regular expressions and I've became totally unglued at what the start method of the Matcher class returns.
    Here's the example...
    Passing in "\d*" ab34ef to the following code
    import java.util.regex.*;
    public class Class1
      public static void main(String []args)
        Pattern p= Pattern.compile(args[0]);
        Matcher m=p.matcher(args[1]);
        boolean b=false;
        while (b=m.find())
          int x=m.start();
          String y=m.group();
          System.out.print(x + y);
    }Gives the output
    01234456
    I understand eveything apart from the 6 character. How can m.start()return 0 (at the start) and 6 at the end when the string being searched is 6 characters long.
    My head hurts.

    The fact that a string is an array of characters under the hood is just an implementation detail, and it's getting in your way. What start() returns is the beginning position of a substring which may have a length of zero.
    The first time through the loop, the regex matches a zero-length substring at the beginning of the target string. That's the position preceding the first character, index 0. Then, because the match didn't consume any characters, the Matcher moves ahead one position before trying again. Another zero-length match, another bump-along, and now it's at index 2. This time, the regex can actually match some characters. It matches the substring "34", and that brings us to the part that's really confusing. Because the previous match consumed some characters, the Matcher doesn't do a bump-along before attempting the next match. It matches a zero-length substring at index 4, right where the previous match ended. Then it bumps along to index five and does another zero-length match.
    Now, you and I know that the character at index 5 is the last one in a string whose length is 6, so there's no reason to look for any more matches at this point. And if the regex were required to match at least one character, the Matcher wouldn't bother trying again. But in this case a zero-length match is considered valid, and there's one more position where that's possible. It does one last bump-along and matches nothing once more.

  • Java reg expressions

    Does anyone know of a regular expression that will parse all of the text not inside tags of an html document and write it out? Even if the html is badly coded with tags that open and do not close on the same line. I am trying to use backreferencing. Here is my code:
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;
    public class parseHTML {
    public static void main(String[] args)
    try
    BufferedReader in = new BufferedReader(new FileReader("In.txt"));
    PrintWriter out = new PrintWriter(new FileWriter("Out.txt"));
    String aLine = null;
    String pattern1 = "<.+>|.*>|<.*(.*)";
    Pattern p1 = Pattern.compile(pattern1);
    while((aLine = in.readLine()) != null)
    Matcher m1 = p1.matcher(aLine);
    if(m1.find())
    StringBuffer sb = new StringBuffer();
    m1.appendReplacement(sb, "$1" + "\n");
    System.out.print(sb.toString());
    out.print(sb.toString());
    m1.reset(aLine);
    in.close();
    out.close();
    catch(IOException exception)
    exception.printStackTrace();
    }

    Does anyone know of a regular expression that will
    parse all of the text not inside tags of an html
    document and write it out?
    No. However, I am rather certain that it is notpossible.
    ANYTHING is possible with regular expressions, its
    just doing it again on different data. Then it gets
    complicated.Nope. It is not possible write only a regular expression which will parse a "balanced" expression which goes to any depth. You can write one which goes to a fixed depth but not an arbritrary one. "Balanced" would be defined for example by opening and closing parenthesis. Or html tags.
    See "Mastering Regular Expressions" by Jeffery E.F. Fridel, Chap 4, the section on Difficulties and Impossibilities.
    Naturally you can write a program, which might even use regular expressions, to do that. But that is not the same.

  • N00b Vi Q/reg expression for html

    How do I wrap <p> </p> tags around paragraphs globally??
    And when I try to wrap <i></i> around a line, i get the error E488: trailing characters.
    :28,32s/.*/<i>&</i>/g
    . I thought this would wrap italic markers around the whole lines from 28 to 32, what am I doing wrong?
    Oh, and if anyone has a link to a good tutorial for n00bs on global substitutions by regular expressions, don't keep it to yourselves. :-)
    Last edited by Reploid (2009-03-06 18:39:35)

    Thx @ Husio. Will experiment with script a little later, trying to learn the basic stuff for now.
    Another question:
    I have sentences like:
    <p><span class=font25>4th completely revised edition</span></p>
    However, I can only seem to substitute the sentences with font0-9. (!)
    This doesn't work:
    :%s<span class=font[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,2
    5,26,27,28,29,30]\+><b>\(.*\)<\/b><\/span>/\1/
    This doesn't work:
    :%s<span class=font[0-9][0-9]*>
    This doesn't work:
    <span class=font[0-9*][0-9*]>
    What would help me get rid of the formatting markup??
    Last edited by Reploid (2009-03-08 12:54:02)

  • LMS 4.0 Compliance Reg Expression Issue

    I'm
    having problems with a regexp, I'm trying to search for multiple patterns in the loopback description field:
    Example:
    Rtr1:
    interface loopback0
    description rndm:text:cursor:1536:blah:blah1
    Rtr2:
    interface loopback0
    description rndm:text:cursor:3072:blah:blah1
    The regular expression that works is:
    +interface Loopback0
    + [#description .*:.*:.*:1536:.*#]
    But that only searches for one instance, what I cannot get to work is the following:
    +interface Loopback0
    + [#description .*:.*:.*:1536|3072:.*#]
    I have tried many variants, but I cannot get the (pipe) to work properly.
    Thanks in advance for any help,
    Craig

    Nope, still no luck, I did have to add \ in front of the
    colons to get the specific location, the asteriks wwould allow it to search for that sting any
    where in the description, but I couldn't get the pipe to work properly still, I've trie
    d moving the hard brackets, paranthesis etc.
    I ended up working around the problem, by creating individual lines:
    +[#description .*\:.*\:.*\:1536\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:3072\:.*\:.*\:.*#]
    +[#description .*\:.*\:.*\:2048\:.*\:.*\:.*#]
    Then running the report, the report gave the output of which commands needed to be "added", so I used a seperate program to determine which devices were non-compliant, IE.
    If router one needed all 3 of those commands, then I knew it did not match any of them, and was non-compliant, if router two only needed 2 of those commands, I knew that it was compliant.
    Kind of a backwards approach, and I would still like to see the search work.
    Thanks for the help,
    Craig

  • Reg : Express Edition Start-up Parameters

    Hi All !!
    Greeetings for the say !!!
    Recently from few days we are facing an issue with SQL Server 2008/2008R2 and 2008 Express edition, After sudden reboot of VM, the SQL Sercices are not starting eventhough it is set to automatic start-up mode.
    Kindly help me in this what has to be done and where the exact issue lies !!
    ============ Regards Mani

    Hello Mani,
    Please see appropriate logs from event viewer and post it here without message or errolog it is difficult to provide any insight.What you can do is you can go to services.msc and try starting SQL Server from there it will not start giving error message please
    post that message here also immediately refer to eventviewer for any more information at that time.
    I guess issue must be with SQL server must be loosing log as service right its common one
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • Reg expression question

    Why does when parsing the string
    "(*&^Max's)()(#" using the regex
    "[a-zA-z]+(.*)[a-zA-z]+"the result is "^Max's" instead of "Max's" I understand that ^ is a regex special character, but do not see why it pops up.

    @OP. You get that output because you have an error in
    your pattern, you should use a-zA-Z and not
    a-zA-z
    That is, the pattern should be:
    "[a-zA-Z]+(.*)[a-zA-Z]+"Kajor "\\p{Alpha}+(.*)\\p{Alpha}+"But I'm a little suspicious of that ".*" int middle. I assume since you're searching for alphas on both sides of it, that for the .* you want "anything except alpha." If that's the case, it becomes "\\p{Alpha}+(\\P{Alpha}*)\\p{Alpha}+"

  • A reg expression bug?

    would this be a regexp bug?
    Pattern patter=Pattern.compile("SYSTEM_ROOT");
               Matcher m=patter.matcher("SYSTEM_ROOT/hello.gif");
               if(m.lookingAt()){
                        System.err.println(m.replaceAll("c://"));
              }An exception is thrown
    java.lang.StringIndexOutOfBoundsException: String index out of range: 3
         at java.lang.String.charAt(String.java:444)
         at java.util.regex.Matcher.appendReplacement(Matcher.java:551)
         at java.util.regex.Matcher.replaceAll(Matcher.java:661)
         at com.titan.software.tbm.io.FileUtil.main(FileUtil.java:161)     

    Yes! sorry I used m.replaceAll("c:\\")
    I just read the issue with \\ in the bug database.
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5024613
    It seems like backslash it not interpreted literally in m..replaceAll("\\\\") so I have to use m.replaceAll("C:\\\\") to achieve what I really want. javac will convert c:\\\\ into c:\\ , then replaceAll will convert c:\\ into c:\
    is this right?
    thanks
    Are you sure you don't have this:m.replaceAll("c:\\") // with backslashesin
    your code? That would cause that exception.

  • Reg expression - how to set patterns

    all,
    i'm struggling to get the pattern thing to work in java - its probably beacuse i dont understand the syntax properly and at moment cant find any proper resourse to point me in the right direction. so although this is probably very easy but all i need to do is split string (1967-1969) into two - ie i want
    var1=1967;
    and var2=1969;i.e in the string want to find the pattern of "-"
    and if found split else its only a single year and just take it as it is
    i'm trying below code but obviously have the syntax wrong
    please can some one tell me how to set the pattern and ideally a resource where i can get a quick ref at the diffrent meaning of the syntax
    Pattern p = Pattern.compile("-(.*?)-");
                      Matcher m = p.matcher(year);
                     boolean b = m.find();
                            if (b == true)
                          String[] result = p.split(year);
                               if (log.isDebugEnabled())
                                   log.debug("a year range was found the values are "+m.group(1));
                                   log.debug("a year range was found the values are lower limit: "+result[0]);
                                   log.debug("a year range was found the values are upper limit: "+result[1]);
                                   }

    String[] result = year.split("-");
    or
    Pattern pattern = Pattern.compile("([^-])+-(.*)");
    Matcher matcher = pattern.matcher(year);
    if (matcher.matches())
    String var1 = matcher.group(1);
    String var2 = matcher.group(2);
    }

Maybe you are looking for