Regular expression in a switch case

Hey guys,
I have a string "52x + 60" and i want to extract 52x and 60 using regular expressions and a switch case
Is this the right way of doing it?
var equation:String = "32x + 5"
var numberExract:RegExp = /\d+/
var xExtract:RegExp = /d+/x/
for(var i:Number=0; i<equation.length; i++)
                    switch(equation.charAt(i))
                              case numberExtract.exec(equation):
                              trace("number");
               break;
               case xExtract.exec(equation):
               trace("x");
               break;
Because it's not tracing anything when i try

Here is a quick and dirty approach - can be customized, optimized and more elegant expressions used:
// equation
var string:String = "x^2 + 5x + 5 - x7 + 8 / 4";
// value replacing xs
var value:Number = 60;
// replace xs with value
// if x comes after digit
string = string.replace(/(?<=\d)x/g, String("*" + value));
// if x comes before digit
string = string.replace(/x(?=\d)/g, String(value + "*"));
// all other xs
string = string.replace(/x/g, String(value));
// remove spaces
string = string.replace(/\s/g, "");
// get pairs with first level math
var pattern:RegExp = /(\d+[\*\^\/]\d+)|\D|\d+/g;
var result:Number = stringToMath(string.match(pattern));
trace("result", result);
function stringToMath(match:Array):Number
    // digits surrounding operator
    var pattern:RegExp = /\d+\D\d+/;
    for (var i:int = 0; i < match.length; i++)
        if (match[i].match(pattern))
            match[i] = String(calculate(match[i]));
    trace("loop result", match);
    return calculteSum(match);
* Calculates sums
* @param    array
* @return
function calculteSum(array:Array):Number
    var result:Number = array[0];
    for (var i:int = 1; i < array.length - 1; i++)
        if (array[i] == "+")
            result += array[i + 1];
        else if (array[i] == "-")
            result -= array[i + 1];
    return result;
* First level math
* @param    string
* @return
function calculate(string:String):Number
    var operator:RegExp = /[\+\*\/\^\-]/g;
    var digits:Array = string.match(/\d+/g);
    var num:Number = 0;
    if (digits && string.match(operator) && digits.length > 1)
        switch (string.match(operator)[0])
            case "*":
                num = digits[0] * digits[1];
                break;
            case "/":
                num = digits[0] / digits[1];
                break;
            case "+":
                num = digits[0] + digits[1];
                break;
            case "-":
                num = digits[0] - digits[1];
                break;
            case "^":
                num = Math.pow(digits[0], digits[1]);
                break;
    return num;

Similar Messages

  • Regular expression to covert pascal case to underscores

    I am looking for a way to use the SQL regular expression support to convert some pascal text into underscore separated words.
    For example:
    IsComplianceActionPossible -> Is_Compliance_Action_Possible.
    What I am confused on is how to get the capital letter back in the output.
    select regexp_replace('IsComplianceActionPossible','[A-Z]','_') from dual
    REGEXP_REPLACE('ISCOMPLIAN
    _s_ompliance_ction_ossibleI am know I am missing something simple. Any help is appreciated.
    Regards, Tony

    ebrian wrote:
    Another option:
    SQL> select regexp_replace('IsComplianceActionPossible','(.)([A-Z])','\1_\2') from dual;
    REGEXP_REPLACE('ISCOMPLIANCEA
    Is_Compliance_Action_Possible
    Most likely it would fit OP's needs, howvever it will not work on one letter words in the middle:
    SQL> select regexp_replace('HereIAm','(.)([A-Z])','\1_\2') from dual
      2  /
    REGEXP_R
    Here_IAm
    SQL> select ltrim(regexp_replace('HereIAm','([A-Z])','_\1'),'_') from dual;
    LTRIM(REG
    Here_I_Am
    SQL> SY.

  • [Flex 4.5.1] Regular Expressions - how to ignore case for cyrillic text /ignore flag doesn't work/ ?

    The only solution to this that I've found is to convert the text to lowercase before matching...
    Is there a more convenient way ?
    Thanks

    The only solution to this that I've found is to convert the text to lowercase before matching...
    Is there a more convenient way ?
    Thanks

  • Regular expressions: serious design flaw?

    I wondered why sometimes, the replaceAll() method works in my code and sometimes it throws a java.util.regex.PatternSyntaxException. I wrote a little test case to show the problem
    private void regularExpressionTest() {
            String escapers = "\\([{^$|)?*+."; //characters to escape to avoid PatternSyntaxException
            String text = "The quick brown fox jumps over the lazy dog.";
            System.out.println("Original: "+text);
            String regExp = "o";
            String word = "HELLO";
            String result = text.replaceAll(regExp, word);
            System.out.println("Replace all '"+regExp+"' with "+word+": "+result);
            text = "The quick brown {animal} jumps over the lazy dog.";
            System.out.println("Original: "+text);
            regExp = "{animal}";
    //        regExp = escapeChars(regExp, escapers); //escape possible regular expression characters
            word = "catterpillar";
            result = text.replaceAll(regExp, word);
            System.out.println("Replace all '"+regExp+"' with "+word+": "+result);
    }//regularExpressionTest()The output is:
    Original: The quick brown fox jumps over the lazy dog.
    Replace all 'o' with HELLO: The quick brHELLOwn fHELLOx jumps HELLOver the lazy dHELLOg.
    Original: The quick brown {animal} jumps over the lazy dog.
    java.util.regex.PatternSyntaxException: Illegal repetition
    {animal}
         at java.util.regex.Pattern.error(Pattern.java:1528)
         at java.util.regex.Pattern.closure(Pattern.java:2545)
         at java.util.regex.Pattern.sequence(Pattern.java:1656)
         at java.util.regex.Pattern.expr(Pattern.java:1545)
         at java.util.regex.Pattern.compile(Pattern.java:1279)
         at java.util.regex.Pattern.<init>(Pattern.java:1035)
         at java.util.regex.Pattern.compile(Pattern.java:779)
         at java.lang.String.replaceAll(String.java:1663)
         at de.icomps.prototypes.Test.regularExpressionTest(Test.java:57)
         at de.icomps.prototypes.Test.main(Test.java:34)
    Exception in thread "main" As the first replacement works as espected, the second throws an Exception. Possible because '{' is a special character for the regular expression API. In case I know the regular expression, i could escape these special characters. But in my generic server app, the strings are all parameters, so the only way for replaceAll() to work is, to escape all possible special characters in the regular expression.
    1. Is there a complete list of all special characters for regular expressions that need to be escaped?
    2. Is there a similar replaceAll() method without regular expressions? So that all occurences of a substring can be replaced by another string? (So far, I wrote my own method but this is of course more time consuming for massive string operations.)

    1. The complete list of specially-recognized characters are listed in the Java 1.4.* API. (Of course, new ones may eventually be added as the regex package matures).
    2. It is time consuming to program in general. You should have written your own utility method that goes through a String using indexOf and building up the String in a StringBuffer, and apparently you did. Now you have the utility method...you no longer need to write that method again.
    3. Or you could have written some kind of method that automatically escapes the specially-recognized characters...

  • Parsing a text file using regular expression

    hi all,
    i have a text file which is delimited by a pipe symbol.
    eg.|4| |2| |1| |abcde| 345 |2000|...................
    can anyone help me writing the regular expression for the above case.
    Thanks

    Would splitting the string into tokens help you?
    String s = "|4| |2| |1| |abcde| 345 |2000|";
    String[] token = s.split("\\|");
    int len = token.length;
    for (int i=0; i<len; i++) {
         String t = token.trim();
         if (!t.equals("")) {
              System.out.println(t);

  • Regular expression for email

    Hi all,
    Can anyone help me to create a regular expression validation for email id? I have tried many combinations from internet regarding this validation, but everyone fails on APEX, although it runs fine in .NET or JAVA.
    Expressions i tried was "^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$", i want to validate email address such as "[email protected]". Can anyone help me in this regard?
    With Regards,
    Sunil Bhatia

    Hello Sunil,
    >> Can anyone help me to create a regular expression validation for email id?
    If you are talking about an email address, it’s not clear to me why you include the ‘http’ string in your regular expression. In any case, I’m using the following:
    ^[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}@[a-zA-Z0-9]{1}[a-zA-Z0-9\.\-]{1,}\.{1}[a-zA-Z]{2,4}$Regards,
    Arie.
    Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • Regular expression - parse version number string

    Hi,
    I try to parse a string using regular expressions but id did not work correctly in all cases.
    The string that i want to parse can have one of the following layout:
    3.4.5.v20090305 or
    3.4.5The first three parts have to be integer values, the last part can be a free string (which is optional).
    I use the following code to parse the version number and extract the parts:
    Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
    Matcher m = versionPattern.matcher(versionString);
    if (!m.find()) {
        throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // assert that we matched every part
    // three groups (without qualifier) or four parts (with qualifier)
    int groups = m.groupCount();
    if (groups != 4) {
         throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // extract the parts
    major = parseInt(m.group(1));
    minor = parseInt(m.group(2));
    micro = parseInt(m.group(3));
    qualifier = m.group(4);The above regular expression works in all cases that i tested, except one.
    The follwoing string is accepted as correct input: (but it shouldn't)
    3.4.5a.v20090305And i get the result:
    major = 3
    minor = 4
    micro = 5
    qualifier = a.v20090305
    Thanks for help or suggestions :)
    Best Regards,
    Michael

    heissm wrote:
    Hi,
    I try to parse a string using regular expressions but id did not work correctly in all cases.
    The string that i want to parse can have one of the following layout:
    3.4.5.v20090305 or
    3.4.5The first three parts have to be integer values, the last part can be a free string (which is optional).
    I use the following code to parse the version number and extract the parts:
    Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
    Matcher m = versionPattern.matcher(versionString);
    if (!m.find()) {
    throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // assert that we matched every part
    // three groups (without qualifier) or four parts (with qualifier)
    int groups = m.groupCount();
    if (groups != 4) {
    throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
    // extract the parts
    major = parseInt(m.group(1));
    minor = parseInt(m.group(2));
    micro = parseInt(m.group(3));
    qualifier = m.group(4);The above regular expression works in all cases that i tested, except one.
    The follwoing string is accepted as correct input: (but it shouldn't)
    3.4.5a.v20090305And i get the result:
    major = 3
    minor = 4
    micro = 5
    qualifier = a.v20090305No, that can't be the output. Perhaps you have some old class files you're executing, because with the code you now posted, that can't be the result.
    To verify this, execute this:
    import java.util.regex.*;
    public class Main {
        public static void main(String[] args) {
            String versionString = "3.4.5a.v20090305";
            Pattern versionPattern = Pattern.compile("(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?");
            Matcher m = versionPattern.matcher(versionString);
            if (!m.find()) {
                throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
            // assert that we matched every part
            // three groups (without qualifier) or four parts (with qualifier)
            int groups = m.groupCount();
            if (groups != 4) {
                 throw new IllegalArgumentException("Version must be in form <major>.<minor>.<micro>.<qualifier>");
            // extract the parts
            System.out.println("1 -> "+m.group(1));
            System.out.println("2 -> "+m.group(2));
            System.out.println("3 -> "+m.group(3));
            System.out.println("4 -> "+m.group(4));
    }and you'll see that the following is the result:
    1 -> 3
    2 -> 4
    3 -> 5
    4 -> nullSome remarks about your pattern:
    "(\\d+)\\.{1}(\\d+)\\.{1}(\\d+)(?:\\.{1}(\\w+))?"All the "{1}" can be omitted they don't add anything to your regex and are only cluttering it up. And you'll probably also want to "anchor" your regex using the start- and end-of-string-meta-characters, like this:
    "^(\\d+)\\.(\\d+)\\.(\\d+)(?:\\.(\\w+))?$"

  • Regular expression help needed

    Hello experts,
    I am looking to implement a search & replace regular expression
    my regular expressions are as follows:
    search regular expression = (test\\s+--\\s*)?this is a test(.*)?
    replace regular expression = (new) brand new test$2
    i.e. The results I require are
    case 1
    input string = test -- this is a test 1999
    correct result = (new) brand new test 1999
    or (since I require the regular expression to be optional)
    case 2
    input string = this is a test
    correct result = brand new test
    How do I implement this using pattern and matcher? Sample code would be useful
    I am having difficulties because matcher.appendReplacement will always replace because my regular expressions are optional. (which is incorrect)
    i.e. I am getting the following incorrect result ((new) is being appended)
    input string = this is a test
    incorrect result = (new) brand new test
    At the moment my non working code is
    StringBuffer sb = new StringBuffer();
    Pattern pattern = Pattern.compile("(test\s+--\s*)?this is a test(.*)?");
    Matcher matcher = pattern.matcher("this is a test");
    if(matcher.find())
    matcher.appendReplacement(sb, "(new) brand new test$2");
    String result = sb.toString();
    System.out.println(result);
    }In the above scenario I want the output to be 'brand new test' without the (new) because the input string did not contain 'test --'
    Hope this makes sense
    Thanks

    For example: StringBuffer sb = new StringBuffer();
    Pattern pattern = Pattern.compile("(test\s+--\s*)?this is a test(.*)");
    Matcher matcher = pattern.matcher("this is a test");
    if(matcher.find())
      matcher.appendReplacement(sb, ""); // copy everything before the match
      if (matcher.start(1) != -1)
        sb.append("(new) ");
      sb.append("brand new test");
      sb.append(matcher.group(2));
    matcher.appendTail(sb); // copy everything after the match
    System.out.println(sb.toString()); Because the first group is optional, you need to find out whether it participated in the match before you add the "(new) " bit. The second group doesn't need to be optional because (1) the subexpression with the group can match nothing, and (2) you don't need to perform a different action depending on what that group did. You just append the captured text, which may be an empty string.

  • XML node name matching with regular expressions

    Hello,
    If i have an xml file that has the following:
         <parameter>
              <name>M2-WIDTH</name>
              <value column="09" date="2004-10-31T19:56:30" row="03" waferID="PUK444150-20">10.4518</value>
         </parameter>
         <parameter>
              <name>M2-GAP</name>
              <value column="29" date="2004-10-31T19:56:30" row="06" waferID="PUK444150-03">2.864</value>
         </parameter>
         <parameter>
              <name>RES-LENGTH</name>
              <value column="29" date="2004-10-31T19:56:30" row="06" waferID="PUK444150-03">2.864</value>
         </parameter>
    Is there anyway i can get a list of nodes that match a certain pattern say where name=M2* ?
    I cant seem to find any information where i can match a regular expression. I see how you can do:
    String expression=/parameter[@name='M2-LENG']/value/text()";
    NodeList nodes = (NodeList) xPath.evaluate(expression, inputSource, XPathConstants.NODESET);
    But i want to be able to say:
    String expression=/parameter[@name='M2-*']/value/text()";
    Is this possible? if so how can i do this?
    Thanks!

    As implemented in Java, XPath does not support regular expressions, but in most cases there are workarounds thanks to XPath functions. Correct me if I'm wrong, but setting your expression against the XML document (i.e. because there are no "name" attributes in the whole document) I think you mean to get the value of the <value> elements that have a <parameter> parent element and a <name> sibling element whose value starts with "M2-". If that is the case, you can use the following query expression:String expression = "//parameter/value[substring(../name,1,3)='M2-']";Sorry if I misunderstood the meaning of your expression, but I hope this will help you get the hang of using XPath functions as a substitute for regular expressions.

  • Troubles with a switch case and final expression?

    Been developing C/C++ for quite a while and still new to Java, and struggling with even the simplest things ... Why isnt this switch/case working?
    have some final "variable" declared in a class contating "constants" like this ...
    public class CConstants {
      public static final int MY_CONSTANT1 = 0x01;
    }Now, If I'm trying to use "MY_CONSTANT1" in a case stateent, I get the error "constant expression required" ?
    CConstants c = new CConstants();
    switch(condition){
      case c.MY_CONSTANT1: { //do some work; break; }
      default: { }
    }I thought this would be a nice idea to increase readability as there will be a long switch/case statement.
    Please help!
    Edited by: George.F on Sep 3, 2009 3:07 AM
    Edited by: George.F on Sep 3, 2009 3:08 AM

    You should refer to that constant as CConstants.MY_CONSTANT1.
    Refering to it via a reference to CConstants is possible but strongly discouraged (infact I'd make CConstants non-instantiable by adding a private constructor).
    Other than that your code should work.
    Could you post a SSCCE that demonstrates your problem.

  • Trying to use regular expressions to convert names to Title Case

    I'm trying to change names to their proper case for most common names in North America (esp. the U.S.).
    Some examples are in the comments of the included code below.
    My problem is that *retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");* does not work as I expect. It seems that the toUpperCase method call does not actually do anything to the identified group.
    Everything else works as I expect.
    I'm hoping that I do not have to iterate through each character of the string, upshifting the characters that follow spaces.
    Any help from you RegEx experts will be appreciated.
    {code}
    * Converts names in some random case into proper Name Case. This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * DAN MARINO --> Dan Marino
    * old macdonald --> Old Macdonald &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * ROY BLOUNT, JR. --> Roy Blount, Jr.
    * CAROL mosely-BrAuN --> Carol Mosely-Braun
    * Tom Jones --> Tom Jones
    * ST.LOUIS --> St. Louis
    * ST.LOUIS, MO --> St. Louis, Mo &lt;-- Avoid City Names plus State Codes
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
    * Basic plan:
    * 1. Strategically create double spaces in front of characters to be capitalized
    * 2. Capitalize characters with preceding spaces
    * 3. Remove double spaces.
    // Make the string all lower case
    String retName = name.trim().toLowerCase();
    // Collapse strings of spaces to single spaces
    retName = retName.replaceAll("[ ]+", " ");
    // "mc" names
    retName = retName.replaceAll("( mc)", " $1");
    // Ensure there is one space after periods and commas
    retName = retName.replaceAll("(\\.|,)([^ ])", "$1 $2");
    // Add 2 spaces after periods, commas, hyphens and apostrophes
    retName = retName.replaceAll("(\\.|,|-|')", "$1 ");
    // Add a double space to the front of the string
    retName = " " + retName;
    // Upshift each character that is preceded by a space
    // For some reason this doesn't work
    retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");
    // Remove double spaces
    retName = retName.replaceAll(" ", "");
    return retName;
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:56 AM
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:57 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hopefully someone will still be able to provide a RegEx solution, but until that time here is a working method.
    Also, if people have suggestions of other rules for letter capitalization in names, I am interested in those too.
    * Converts names in some random case into proper Name Case.  This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * CAROL mosely-BrAuN --&gt; Carol Mosely-Braun
    * carol o'connor --&gt; Carol O'Connor
    * DAN MARINO --&gt; Dan Marino
    * eD mCmAHON --&gt; Ed McMahon
    * joe amcode --&gt; Joe Amcode         &lt;-- Embedded "mc"
    * mr.t --&gt; Mr. T                    &lt;-- Inserted space
    * OLD MACDONALD --&gt; Old Macdonald   &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * old mac donald --&gt; Old Mac Donald
    * ROY BLOUNT,JR. --&gt; Roy Blount, Jr.
    * ST.LOUIS --&gt; St. Louis
    * ST.LOUIS,MO --&gt; St. Louis, Mo     &lt;-- Avoid City Names plus State Codes
    * Tom Jones --&gt; Tom Jones
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
         * Basic plan:
         * 1.  Strategically create double spaces in front of characters to be capitalized
         * 2.  Capitalize characters with preceding spaces
         * 3.  Remove double spaces.
        // Make the string all lower case
        String workStr = name.trim().toLowerCase();
        // Collapse strings of spaces to single spaces
        workStr = workStr.replaceAll("[ ]+", " ");
        // "mc" names
        workStr = workStr.replaceAll("( mc)", "  $1  ");
        // Ensure there is one space after periods and commas
        workStr = workStr.replaceAll("(\\.|,)([^ ])", "$1 $2");
        // Add 2 spaces after periods, commas, hyphens and apostrophes
        workStr = workStr.replaceAll("(\\.|,|-|')", "$1  ");
        // Add a double space to the front of the string
        workStr = "  " + workStr;
        // Upshift each character that is preceded by a space and remove double spaces
        // Can't upshift using regular expressions and String methods
        // workStr = workStr.replaceAll("( [^ ])([^ ]+)", "$1"toUpperCase() + "$2");
        StringBuilder titleCase = new StringBuilder();
        for (int i = 0; i < workStr.length(); i++) {
            if (workStr.charAt(i) == ' ') {
                if (workStr.charAt(i+1) == ' ') {
                    i += 2;
                while (i < workStr.length() && workStr.charAt(i) == ' ') {
                    titleCase.append(workStr.charAt(i++));
                if (i < workStr.length()) {
                    titleCase.append(workStr.substring(i, i+1).toUpperCase());
            } else {
                titleCase.append(workStr.charAt(i));
        return titleCase.toString();
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Regular Expression Search for Case Statement in VBA

    Hi,
    I'm having trouble trying to use regular expressions in a case statement. I have a CSV spreadsheet of a server's netstat output and am trying to plot everything into Visio. I have been able to do that, however I'm not trying to expand this capability and
    resuse the same code for many different servers. 
    I have the mainServer variable set as a Variant and in my current example it is set as "INTPXY001" (internal proxy server 001). I have tried different regex statements for the potential to have INTPXY001 - INTPXY999, EXTPXY001 - EXTPXY999, and
    SVCPXY001 - SVCPXY999 in place of the Case "INTPXY001", but nothing I have tried seems to work.
    '========================================
    Set mainServer As Variant
    Set AppVisio = CreateObject("visio.application")
    AppVisio.Visible = True
    AppVisio.Documents.AddEx "", visMSDefault, 0
    AppVisio.Documents.OpenEx "server_u.vss", visOpenRO + visOpenDocked
    mainServer = ActiveSheet.Cells(1, 2) 'sets mainServer to INTPXY001
    With AppVisio.ActiveWindow.Page
    Select Case mainServer
    Case "INTPXY001"
    .Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.ItemU("Proxy server"), 2.25, 9.25
    Case Else
    .Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.Item(("Server"), 2.25, 9.25
    End Select
    End With
    '========================================

    You cannot declare variables As Variant in VBScript. All variables in VBScript are implicitly variants.
    If you are asking about VBA (Visual Basic for Applications), then you're not asking in the correct forum.
    -- Bill Stewart [Bill_Stewart]

  • How to make a regular expression case insensitive?

    Hi,
    I am using SAP UI5 .
    I am validating the user input using a regular expression to make sure user dose not enter a keyword which is reserved.
    var regexAppID = /^(?=^(?:(?!(^Admin$|^AdminData$|^Push$|^smp_cloud$|^resource$|^test-resources$|^resources$|^Scheduler$|^odata$|^applications$|^Connections$|^public|^Public$|[\.]{2,}|^[\.])).)*$)(?=^[a-zA-Z]+[a-zA-Z0-9_\.]*$).*$/;
    textField.mBindingInfos.value.type.oConstraints.search = regexAppID;
    The regex blocks the user from entering the keywords Admin,AdminData etc.
    It works fine if the user enters the value as it is given in regex (ie case sensitive example "Admin").
    But when user enters "admin" or "aDmin" etc the regex is not catching it and my server crashes as it bypasses these keywords.

    Can't you use this expression?
    ^/(?!ignoreme$)(?!ignoreme2$)[a-z0-9]+$
    Then you will have only a match when the word is something else then "ignoreme" or "ignorme2".
    Why don't you just check it in an IF statement? if(input==="ignoreme" or ... ) ? It's both static.. or you could put all options in an array and use the statement indexOf to find if it is in the array.
    JavaScript Array indexOf() Method
    Kind regards,
    Wouter

  • Regular Expression to Filter Out Special Case

    I wonder if anybody knows how to use regular expressions to match any possible string in existence, exception one?
    For example, lets say the string I DON'T want to match is "Foo".
    Then I want a regular expression that will match (and capture) everything except EXACTLY "Foo". Therefore, "FooBar" is ok, "FooFoo" is ok, "Fool" is okay, "Java" is okay, "Supercalifragilistic Expialadocious" is okay. Absolutely anything, exception exactly "Foo".
    Does anybody know if or how this can be done, using regular expressions (I know I could simply test for .equals, but the problem is, I don't have control of the code that does the validation. All I can do is supply a regular expression, and let the framework do the rest).
    Thanks,
    Adam

    I guess I don't follow you when you say you have to use regexs, since you provide a regex to split().
    Do you mean you can only use Pattern and matches(), etc?
    I'm just curious now, since it looks like Sabre150 provided a solution to your problem.

  • ReplaceAll string by regular expression not work for this case.

    I will delete all tag and want "pure text" but the output is delete all.
    String content = "<aaa>pure text<fff>";
    content = content.replaceAll("<.*>","");Content has output is blank because reqular expression match from begin and end of string
    But when i change
    String content = "<aaa>pure text<fff";
    content = content.replaceAll("<.*>","");The output is ==> pure text<fff
    How make req match in sequential
    Please lead me to solution

    peterdog1234 wrote:
    Thank you very much.
    I know '?' is a Quantifiers.
    I do not understand using ?
    Please lead me againSee the paragraph "Laziness Instead of Greediness" from [http://www.regular-expressions.info/repeat.html].

Maybe you are looking for

  • Allow certain users to capture quotation after bid end date

    Hi Is it possible to allow certain users to be able to capture quotation on behalf of suppliers using surrogate bid after the end date has been reached but before the opening date? How would I do this? Regards

  • How to import Essbase app from 7.1 to 11.1.2.1?

    Hi, I need for migration my environment from Essbase 7.1 to 11.1.2.1. How to import Essbase app from 7.1 to 11.1.2.1?

  • FM in HR

    Hi,   Is there any FM for reverse postings? Once the document has been reversed , we cant reverse the document again in a day. Does anyone knows how to do this?

  • Remove C:\Program Files\sapinst_instdir after successful installation

    Hello, do you recommend to delete the directory C:\Program Files\sapinst_instdir after successful installation. It wastes ~500 MB disk space. Thanks, Juergen

  • Urgent::Installing PDK on WAS 2004s

    Hi, I have installed WAS 2004s, and want to start with portal development. For this i downloaded PDK 6.0.14. <b>Could you please tell me if there will be any compatibilty issues?</b> Also, for its installation i didnt find the required following role