WebTest - VS2013 - Extract Regular Expression - Required=False

I have an "Extract Regular Expression" that may or may not be able to extract a value. I set the property value of Required to False. The next block checks for the existence of that Context Parameter. If the Context Parameter is there, it does
some work, if the Context Parameter is not there, it skips the condition.
When I run my WebTest, it tells me that it passes the extraction rule but it never created the Context Parameter so the condition is skipped.
If I set Required=True, everything works as expected.
I remembered that there was a defect in VS2010 with the Required=False, so I added this Extraction Plug-In 
[DisplayName("Extract Regular Expression Not Required")]
[Description("Extract text matching a regex and add it to the test context. If no match is found, do not fail webtest. This gets around a VSTS bug where 'Required' property of the Extract Regular Expression rule is not honored.")]
public class ExtractRegularExpressionNotRequired : ExtractRegularExpression
public override void Extract(object sender, ExtractionEventArgs e)
base.Extract(sender, e);
e.Success = true;
That too passes the regular expression but fails to create the Context Parameter.

By setting the Required parameter to False, I am expecting that a Context Parameter does not get created if the regular expression is not found and that is does get created if the regular expression is found.
So when I run my test, it tells me that the regular expression was found but my Context Parameter was not created. 
When I created this webtest in VS2010, I found that there was a bug with the Extract Regular Expression when the Required property was False. This
thread showed the code for a custom Extraction rule to fix the problem. When I run this webtest in VS2013, both the built-in Extract Regular Expression and the custom Extract Regular Expression Not Required are not creating the Context Parameter if the
regex is found.
Try this yourself:
Create a webtest
Add "Extract Regular Expression"
Set the Regular expression to . (this will match any one character)
Set the Requiredto False
Set the Context Parameter Name to TEST
Run the webtest
Although the result from the extraction rule will be Passed, there is no Context Parameter TEST created. 
If you create the custom Extract Regular Expression Not Required plugin, the same problem occurs.

Similar Messages

  • Regular Expression Required for Checksum variable

    I am wanting to create a regular expression that extracts a variable checksum value (cs=) which is unique to a given server response string.
    The issue I am having is that a simple regex being name="cs" value="(.+?)" just does not work because there are 18 different checksum values being returned per session id/server response.
    So a simple regex just picks up any "cs" value and I guess gets confused since there are 18 different ones contained within the server response (all user related)
    What i need is a regex to use say this value from the server response (JONHONEYMAN%40YAHOO.COM) or any other unique value which is contained within the string response from the server then extract the cs (Checksum) value from that string and make it variable :)
    Here is the server response string:-
    "fp=220:1200:2977638312763704:: NO::P1200_EMAIL_ADDRESS,P1200_ORGANISATION_NAME,P1200_UCRN,P1200_ORG_ID,P1200_CALLING_PAGE:JONHONEYMAN%40YAHOO.COM%2C john%20Honeyman%2C260%2C220%2C1190&cs=336788D01EC6E80B1877B3EE982E8B2D8" >Select</td></tr
    can anyone help?
    Thanks

    You need an XML Parser.

  • Use regular expressions to extract .llb filename from path

    I am trying to be clever (always a dangerous thing) and use a regular expression to extract the name of a library from a filepath converted to a string.   Whilst I appreciate there are other ways to do this, regex would appear to be a very powerful neat way, should I be able to get it to work.
    i.e if I have a string of the type, C:\applications\versions\library.llb\toplevel.vi, I want to be able to extract library.llb from the string, given that it will be of variable length, may include numbers & spaces and may be within a file hierarchy of variable depth.   In other words, I want to extract the portion of the string between the last \ that ends with .llb
    The best I have managed so far, is \\+.*llb which returned everything minus the drive letter and the toplevel.vi
    Can anyone help me achieve this, or am i better using an alternative method (e.g filepath to array string, search for .llb)
    Thanks
    Matt
    Solved!
    Go to Solution.

    Hi Matt,
    attached you'll find two other options.
    Mike
    Message Edited by MikeS81 on 04-13-2010 01:30 PM
    Attachments:
    Path.PNG ‏7 KB

  • Extracting text from a file name on export / import (Regular Expressions??)

    I’m not even sure if the publishing service, File Naming, in Lightroom supports Regular Expressions or not?? Basically I’m trying to extract the left portion of the file name ie: everything before the underscore “_”. When I import a file I rename the file to reflect the current Image sequence number and then append the date the photo was taken; a typical file is as follows “05625_2008-01-05.dng” on export I would like the new name to be only the sequence number in this case “05625.jpg”. Ideally I would then like to append the folder name that contains the file… “05625 - FolderName.jpg.
    I don’t want to go down the road of figuring out the correct syntax if regular expressions aren’t supported. Thanks in advance - CES

    Is the imported sequence number captured in meta data somewhere or is their somewhere that all of the available fields and there reference names can be found???
    Unfortunately not anywhere available to the user (but it's still stored in at least some filed I know off).
    By the way, why did you choose to put the suffix at the beginning of the name (1234_2010-08-13.jpg)? The common practice is to leave the suffix at the end. That will ensure the filenames will sort in chronological order by filename and you could have easily used the suffix when exporting files. You wouldn't have this problem now.

  • Requirements gateway & regular expressions

    I'm trying to create a regular expression that will match a Requirement ID type in a MS Word document using Requirements Gateway.
    Our syntax for a Requirement ID is as follows:
        '* shall [::requirement id] *'
    An example would be
        'The system shall [::requirement1] self destruct after 1 minute of use.'
    I'm using the following RE.
        shall[ \t]*\[[ \t]*(.*):.+)\]
    I've been able to get it to match 'most' of Requirement ID's ,but a few aren't caught...most noteably those Requirement ID's that run past the end of the
    line.
    When 'shall' is on one line and '[::requirement1]' is on the next, the Requirement ID isn't matched.
    Are there any limitations to the RE engine that Requirements Gateway uses?
    If not, any help with the RE would be MUCH appreciated.
    thanks
    Pat

    Allen,
    Thanks for the advice.  Unfortunately it didn't help
    Again, our requirements are identified by a 'shall' followed by a tag in brackets. 
    Ie  The unit shall [<optional source>::requirement id] be expensive.
    The RE, "shall\[(.*):.+)\]" doesn't always work. (Sorry for the embedded emoticon)
    Most of the time it identifies the tag but says
    Requirement ' : XYZ' can't be covered.
    Error: Requirement defined several times
    Other times is combines two tags into one.
    I'm attaching the modifed type and the doc thats causing the problems.
    Thanks for your continued help,
    Pat

  • Requirement to update a column by using Regular Expression

    Hi All,
        I have a requirement to update a column which is having values like below code.
    based on the conditinos I need to update from ‘E’ to ‘Z’.  Few positions I need to update and remaining positions I need leave as it is.
    How I can achive this requirement by using regular expression regexp_replace.
    Actual value --> 'AEAAAEAA    EE    AA    EE    AA    EE    EEEAA    AA    AA       '
    After update -->  'AZAAAZAA    EE    AA    EE    AA    EE    EEEAA    AA    AA       '

    below is my requirement. I am adding the conditions dynamically as per the conditions. I dont know the position of the E. If 'E' is in any position I need to update with 'Z' if that 'E' satisfy the condition.
    I dont want to update all the E's to Z's.
    I want to update specific E's which satisfy the condition.
        IF l_kwhhilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,1,1) = ''E'' OR ';
            l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\1';
        END IF;
        IF l_kwhilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,2,1) = ''E'' OR ';
             l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\2';
        END IF;
        IF l_kvahilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,3,1) = ''E'' OR ';
             l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\3';
        END IF;
        IF l_kvarhilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,4,1) = ''E'' OR ';
             l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\4';
        END IF;
        IF l_todkwh1hilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,5,1) = ''E'' OR ';
             l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\5';
        END IF;
        IF l_todkwh2hilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,6,1) = ''E'' OR ';
             l_exp := l_exp||'Z';
        ELSE
            l_exp := l_exp||'\6';
        END IF;
        l_exp := ''''||l_exp||'''';
        l_exp1 := '\1\2\3\4'||l_exp1;
        IF l_todkw1hilow >= 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,11,1) = ''E'' OR ';
             l_exp1 := l_exp1||'Z';
        ELSE
            l_exp1 := l_exp1||'\5';
        END IF;
        IF l_todkw2hilow = 1 THEN
            l_where := l_where||' SUBSTR(OVERRIDEFIELD,12,1) = ''E'' OR ';
             l_exp1 := l_exp1||'Z';
        ELSE
            l_exp1 := l_exp1||'\6';
        END IF;
        l_exp1 := ''''||l_exp1||'''';
    IF i give 10 in the regexp_replace it is not working.
    SET OVERRIDEFIELD =     REGEXP_REPLACE(SUBSTR(overridefield,1,6), ''(.)(.)(.)(.)(.)(.)'','||l_exp||')'||
                                              ' ||REGEXP_REPLACE(SUBSTR(overridefield,7,6), ''(.)(.)(.)(.)(.)(.)'','||l_exp1||')'||
                                              ' ||SUBSTR(overridefield,13)'||

  • Regular Expression - Extract words before the PLUS Sign ?

    Dear All,
    I had many words with having a symbol plus. I need to extract the words before the plus sign.
    I can able to do this by using String.indexOf or String.contains. But i like to know is there is any way to do this using Regular Expression.
    sample string
    Kathire+san Output Kathire
    World+islike Output World
    Thanks,
    J.Kathir

    Here's one way.
    import java.util.regex.Pattern;
    String input = "abc+def";
    Pattern pat = pat.compile("\\+");
    String beforePlus = pat.split(input)[0];
    Sun's Regular Expression Tutorial for Java
    Regular-Expressions.info

  • Extract values with Regular Expression

    How to extract values into [ ] using regular expression.
    With data As
    Select 'AAAAAA[10] AAA: 19C' Txt From Dual Union all
    Select 'XX[450]-10A' Txt From Dual Union all
    Select '[5]AVC19C' Txt From Dual Union all
    Select 'FVD[120]D2AC' Txt From Dual
    )I hope this return
    10
    450
    5
    120Thanks in advanced

    user11118871 wrote:
    Thanks for all.
    Hi BluShadow, can you explain what this is doing!?
    ThanksSure.
    Search for ----------------|           /------- Replace the found pattern in the search string with backreference 1
                         /------------\   /\       (the first thing backreferenced in the search string)
    regexp_replace(txt, '^.*\[(.*)\].*$','\1')
                         |\/\/\--/\/\/|
                         | \ \  /  \ \|
                         | | |  |  | |\- End of string
                         | | |  |  | |
                         | | |  |  | \- Any number of characters
                         | | |  |  |
                         | | |  |  \- Right square bracket (escaped)
                         | | |  |
                         | | |  \- any characters (backreferenced by round brackets)
                         | | |
                         | | \- Left square bracket (escaped)
                         | |
                         | \- Any number of characters
                         |
                         \- Start of stringEdited by: BluShadow on Jun 29, 2009 2:19 PM

  • String extract using regular expression

    Hi
    I have text like this "<a>45</a><ct>Hi</ct><R>45 85</R><H>Here</H>" .I want to extract using regular expression or any techniques the text between <R> and </R> also need to replace the space with pipe between 45 and 85 like "45|85"
    Edited by: vishnu prakash on Mar 2, 2012 4:42 AM

    Hi,
    Here's one way:
    REPLACE ( REGEXP_REPLACE ( txt
                    , '.*<R>(.*)</R>.*'
                    , '\1'
         , '|'
         )This assumes there is only one <R> tag in txt.
    Always say which version of Oracle you're using. The expression above will work in Oralce 10 and up, but starting in Oracle 11 you can use REGEXP_SUBSTR rather than the less intuitive REGEXP_REPLACE.
    Edited by: Frank Kulash on Mar 2, 2012 7:48 AM

  • Extracting Content with Regular Expressions

    hi all,
    i am trying to extract some content from a text file using regular expressions but i am unable to get the exact match that i am expecting
    here is the sample text
    The passage begins like that (something in text form (some
    more embedded text) remaining outer text).
    i am expecting to get the following match,
    (something in text form (some
    more embedded text) remaining outer text)
    but my regular expression just returns me a broken section of the text as this one
    (something in text form (some
    more embedded text)
    how can i get this fixed, i mean how can i match evenly across the open parenthesis.
    here is my broken reg exp (?:\((?:\\.|[^\)\\])*\))
    thanks for any help!

    Cross-posted. See duplicate http://forum.java.sun.com/thread.jspa?threadID=653042&tstart=0

  • Regular expression to extract value from xml

    Hi,
    I need to extract the value of an XML tag.
    <purchaseId>Best-200423</purchaseId>
    The result of the expression should be: "Best-200423".
    Something like this ([^\\<purchaseId\\>]*[^\\</purchaseId\\>]) does not work.
    Does somebody has a soltuion?
    I can't get it to work! I want to use the Java Regular Expression functionality.
    Best wishes
    Jochen

    You got lucky, is all. Try changing "Best" to "pest" in your example and it won't work. The square brackets are spurious, and you want m.getGroup(1) to get the stuff that matches the () group.
    Square brackes mean "match any of the characters in the brackets". [^ means "match any character not in this list").                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Extract time and data with a regular expression

    Hi,
    I have a string with time and date in a HTML statement.
    String s =">19:59, 18 August 2006</a> ";
    // I hope get
    String s1="19:59, 18 August 2006";or
    String s =">18:37, 4 September 1998</a>"Because of different length of months, so how use regular expression to extract it.
    The second question is how to write the string into a file.
    filename =  "A.txt";
                    File file = new File(filename);
              out=new BufferedOutputStream(
                        new FileOutputStream(file));
                   byte[] buffer = new byte[1024];
    // then what?Thank you in advance!

    If "WARNING" can never occur in the input then wedon't have to worry about making the regex not match
    it.
    Hmm, how about fool-proof? :)Bad idea, and impractical or impossible to implement. Excessively defensive coding leads to bloated, hard to maintain code, and a greater likelihood of bugs.
    Code so that you code works correctly provided the preconditions are met. It's the caller's responsibility to meet them. Don't waste time and gunk up your code trying to handle inputs that aren't allowed to occur.

  • Evaluating a String True/False with a Regular Expression

    I need to write a regular expression to make the following strings display the values of true/false:
    112 Elm Street True
    112 South Elm St. True
    112 S. Elm True
    Elm St. False
    South 112 Elm False
    Here's what I have so far:
    public class MethodOne
         public static void main (String args[])
              return street.matches (//d+//s+[A-Z]{1}[a-z][.]?//s{1}[A-Z]{1}[a-z]+[.]);
            String address1 = "112 Elm Address"
            String address2 = "112 South Elm St."
            String address3 = "112 S. Elm"
            String address4 = "Elm St."
            String address5 = "South 112 Elm"
            if (address1.matches(street) ) {
            System.out.println("True");
            else {
            System.out.println("False")
               }// end if
         Can anyone help me out?

    Is this what you want?
    String address1 = "112 Elm Street";
    String address2 = "112 South Elm St.";
    String address3 = "112 S. Elm";
    String address4 = "Elm St.";
    String address5 = "South 112 Elm";
    String matchString = "\\d+ [A-Z,a-z,. ]+";
    System.out.println(address1.matches(matchString));
    System.out.println(address2.matches(matchString));
    System.out.println(address3.matches(matchString));
    System.out.println(address4.matches(matchString));
    System.out.println(address5.matches(matchString));

  • NIRG LabVIEW regular expression for covering multiple requirements

    The Word document type in NI Requirements Gateway allows for comma separating the requirements in a Reference / coverage statement.  I would like to do the same within my LabVIEW code, but the type does not have the same Sub regular expression field available.  Is there any way to have a LabVIEW regular expression find coverage statements such as the following:
    [Covers: REQ-5, REQ-9, REQ-15]
    currently within LabVIEW comments I have to have 3 separate [Covers: REQ-5] type statements

    cdweiss,
    I'm very interested to know if you have any other feedback on NI Requirements Gateway.  I'd also be curious to know what products are you're using with it and how extensive your requirements are.
    Feel free to email me directly at [email protected]
    Cheers,
    Eli 
    Message Edited by Elijah K on 01-19-2010 11:40 PM
    Elijah Kerry
    Senior Product Manager, LabVIEW
    Follow my Software Engineering for LabVIEW Blog

  • Regular Expression help required

    {color:#000000}Hi....
    I am having a product table in oracle with products like CZS20T and CZSS30T and so on....
    But for printing on the invoice we need only the product name without the micron thickness like CZS and CZSS{color}{color:#000000}
    I tried regular expression with....."select regexp_substr('CZSS20T','([[:digit:]]{2})') from dual"
    {color}
    and the result was "20"*...*
    But I cant figure out how to use regular expression to get only the product name.
    Maybe there is another way without using Regular exp...
    Please help....

    regexp_substr (prod, '[[:alpha:]]*')and an example:
    SQL> with x as
      2  ( select 'CZS20T' prod from dual union all
      3    select 'CZSS30T' from dual union all
      4    select 'A10CSD' from dual
      5  )
      6  select prod
      7       , regexp_substr (prod, '[[:alpha:]]*')
      8    from x
      9  ; 
    PROD    REGEXP_SUBSTR(PROD,'[[:ALPHA
    CZS20T  CZS
    CZSS30T CZSS
    A10CSD  A
    SQL> Edited by: Alex Nuijten on Jan 27, 2009 8:52 AM

Maybe you are looking for

  • Batch Edit Multiple HTML files | Find and Replace

    Hi, I would like to use Automator to automate (I know that sounds redundant) the following process. 1. Take a group of html files 2. Open each file so it can find and replace the script of any image folders Example: Change: img src="home_files/photo.

  • Filtering one dropdown on the basis of value from another dropdown in WAD

    Hi All, i have a bw dropdown called 'Corporate' and another called 'Facility'. there can be several facilties under a Corporate. what i need to do is filter the facility dropdown on the basis of the value selected in the corporate dropdown. thanks in

  • ITunes doesn't open any more, what the **** is going on NOW!?

    I previously posted a problem for my desktop computer, see: 1607: Unable to install InstallShield Scripting Runtime. BUT NOW, I updated iTunes on my laptop since I can't get iTunes to work on my desktop with out getting the above message and after I

  • PMU Problem or Battery????

    I have posted my issue elsewhere in here so won't go into too much detail, but my battery life took a drastic drop yesterday after charging it (it lasted 3 hours, then after charge only lasted 20 minutes). It now states 69 cycles and only 544 mAh cap

  • SAFARI 7.0.1 SLOW SLOW SLOW SLOW

    Safari 7.0.1 long wait times.