Parse Mac Address with match regular expression

Hi Everyone,
I have a problem with the Match Regular Expression function,
I am trying to parse the response two a arp -a 192.168.0.15 request in order to extract MAC address of this remote IP, I used the following RegEx: ^([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})$
I am wondering why do I need to do a string subset first to extract only the MAC Address part. Isn't Match Regular Expression function capable of recognizing the RegEx directly in the middle of a string?
I only works when I extract the right tring subset as in the picture bellow.
Thanks for your answers.
Solved!
Go to Solution.
Attachments:
Mac Address.JPG ‏40 KB

Get rid of the "^" in the beginning of your regular expression. You are instructing it to find the pattern at the beginning of the string.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot

Similar Messages

  • Match Regular Expression not returning submatches.

    I am having an issue with Match Regular Expression not returning the appropriate number of submatches.  My string is as follows:
    DATAM    995000    1.75    0.007    -67.47    24.493    99.072
    The spaces are tabs and the length is not fixed so simple string manipulation is out of the question.  The regular expression I was trying is as follows:
    (?<=\t)[0-9\.\-]*(?=(\t|$))
    It successfully returns Whole Match as the first number but no submatches are returned.  I've tried simpler expressions which work in Matlab and EditPad Pro such as [0-9.-]* but never got the same answer in Labview.
    What is going on?

    Here is an image of the VI.  The top portion is the input from our Licor 7000.  The bottom portion is the bit of code I'm having problems with.
    Attachments:
    matchregularexpression.jpg ‏336 KB

  • Problems with java regular expressions

    Hi everybody,
    Could someone please help me sort out an issue with Java regular expressions? I have been using regular expressions in Python for years and I cannot figure out how to do what I am trying to do in Java.
    For example, I have this code in java:
    import java.util.regex.*;
    String text = "abc";
              Pattern p = Pattern.compile("(a)b(c)");
              Matcher m = p.matcher(text);
    if (m.matches())
                   int count = m.groupCount();
                   System.out.println("Groups found " + String.valueOf(count) );
                   for (int i = 0; i < count; i++)
                        System.out.println("group " + String.valueOf(i) + " " + m.group(i));
    My expectation is that group 0 would capture "abc", group 1 - "a" and group 2 - "c". Yet, I I get this:
    Groups found 2
    group 0 abc
    group 1 a
    I have tried other patterns and input text but the issue remains the same: no matter what, I cannot capture any paranthesized expression found in the pattern except for the first one. I tried the same example with Jakarta Regexp 1.5 and that works without any problems, I get what I expect.
    I am using Java 1.5.0 on Mac OS X 10.4.
    Thank to all who can help.

    paulcw wrote:
    If the group count is X, then there are X plus one groups to go through: 0 for the whole match, then 1 through X for the individual groups.It does seem confusing that the designers chose to exclude the zero-group from group count, but the documentation is clear.
    Matcher.groupCount():
    Group zero denotes the entire pattern by convention. It is not included in this count.

  • What's wrong with the regular expression?

    Hi all,
    For the life of me I can not figure out what is wrong with this regular expression
    .*\bA specific phrase\.\b.*
    This is just an example the actual phrase can be an specific phrase. My problem comes when the specific phrase ends in a period. I've escaped the period but it still gives me an error. The only time I don't get an error is when I take off the end boundry character which will not suffice as a solution. I need to be able to capture all the text before and after said phrase. If the phrase doesn't have a period it would look like this...
    .*\bA specific phrase\b.*
    which works fine. So what is it about the \.\b combination that is not matching?
    I've been banging my head on this for a while and I'm getting nowhere.
    The application highlights text that comes from a server. The user builds custom highlights that have some options. Highlight entire line, match partial word, and ignore case. The code that builds my pattern is here
    String strHighlight = _strHighlight;
            strHighlight = strHighlight.replaceAll("\\*", "\\\\*");
            strHighlight = strHighlight.replaceAll("\\.", "\\\\.");
            String strPattern = strHighlight;
            if(_bEntireParagraph)
                if(_bPartialWord)
                    strPattern = ".*" + strHighlight + ".*";
                else               
                    strPattern = ".*\\b" + strHighlight + "\\b.*";           
            else
                if(_bPartialWord)
                    strPattern = strHighlight;
                else               
                    strPattern = "\\b" + strHighlight + "\\b";  
            if(_bIgnoreCase)
                _patHighlight = Pattern.compile(strPattern, Pattern.CASE_INSENSITIVE);
            else
                _patHighlight = Pattern.compile(strPattern);So for example I matching the phrase: The dog ate the cat. And that phrase came over in the following text: Look there's a dog. The dog ate the cat. "Oh my!"
    And my user has the entire line and ignore case options selected then my regex woud look like this: .*\bThe dog ate the cat\b.*
    That should get highlighted, but for some reason it doesn't. Correct me if I'm wrong but doesn't the regex read as follows:
    any characters
    word boundry
    The dog ate the cat[period]
    word boundry
    any characters until newline.
    Any help will be much appreciated

    A word boundary (in the context of regexes) is a position that is either followed by a word character and not preceded by one (start of word) or preceded by a word character and not followed by one (end of word). A word character is defined as a letter, a digit, or an underscore. Since a period is not a word character, the only way the position following it could be a word boundary is if the next character is a letter, digit or underscore. But a sentence-ending period is always followed by whitespace, if anything, so it makes no sense to look for a word boundary there. I think, instead of \b, you should use negative lookarounds, like so:   strPattern = ".*(?<!\\w)" + strHighlight + "(?!\\w).*";

  • Match Regular Expression does not match what Match Pattern does

    I have read through a lot of posts about how Match Pattern does not match what Match Regular Expression will due to not processing some characters.
    However, I found a problem with the other way. A simple Reg-Ex that works in Match Pattern but not Match Regular Expression.
    What I have here is just an example. I want to use Match Regular Expression so I can specify some sub-matches.
    The reg-ex is for: one or more non-numeric characters, a space, one or more numeric characters. At the start of the string.
    How can I get this working in Match Regular Expression? I am working in LabVIEW 2010f2 32 bit. Here is the code snippet and the results:
    Rob
    Solved!
    Go to Solution.

    Robert Cole wrote:
    I think I prefer the ~ for negation since ^ is also used for beginning of the string. But we work with what we have.
    Let me offer you a tip and perhaps defend the honor of the regex a little bit.  One of my favorite features of regexes is the ability to specify character classes (and their negation).  One of the reasons I have to think about the ~ versus ^ is that I rarely use ^ in a regex alternative. 
    Some examples:
    [0-9] = \d (digit)
    [^0-9] = \D (not a digit)
    The equivalent regex for your case is: \D+ \d+

  • "Match Regular Expression" and "Match Pattern" vi's behave differently

    Hi,
    I have a simple string matching need and by experimenting found that the "Match Regular Expression" and "Match Pattern" vi's behave somewhat differently. I'd assume that the regular expression inputs on both would behave the same. A difference I've discovered is that the "|" character (the "vertical bar" character, commonly used as an "or" operator) is recognized as such in the Match Regular Expression vi, but not in the Match Pattern vi (where it is taken literally). Furthermore, I cannot find any documentation in Help (on-line or in LabVIEW) about the "|" character usage in regular expressions. Is this documented anywhere?
    For example, suppose I want to match any of the following 4 words: "The" or "quick" or "brown" or "fox". The regular expression "The|quick|brown|fox" (without the quotes) works for the Match Regular Expression vi but not the Match Pattern vi. Below is a picture of the block diagram and the front panel results:
    The Help says that the Match Regular Expression vi performs somewhat slower than the Match Pattern vi, so I started with the latter. But since it doesn't work for me, I'll use the former. But does anyone have any idea of the speed difference? I'd assume it is negligible in such a simple example.
    Thanks!
    Solved!
    Go to Solution.

    Yep-
    You hit a point that's frustrated me a time or two as well (and incidentally, caused some hair-pulling that I can ill afford)
    The hint is in the help file:
    for Match regular expression "The Match Regular Expression function gives you more options for matching
    strings but performs more slowly than the Match Pattern function....Use regular
    expressions in this function to refine searches....
    Characters to Find
    Regular Expression
    VOLTS
    VOLTS
    A plus sign or a minus sign
    [+-]
    A sequence of one or more digits
    [0-9]+
    Zero or more spaces
    \s* or * (that is, a space followed by an asterisk)
    One or more spaces, tabs, new lines, or carriage returns
    [\t \r \n \s]+
    One or more characters other than digits
    [^0-9]+
    The word Level only if it
    appears at the beginning of the string
    ^Level
    The word Volts only if it
    appears at the end of the string
    Volts$
    The longest string within parentheses
    The first string within parentheses but not containing any
    parentheses within it
    \([^()]*\)
    A left bracket
    A right bracket
    cat, cag, cot, cog, dat, dag, dot, and dag
    [cd][ao][tg]
    cat or dog
    cat|dog
    dog, cat
    dog, cat cat dog,cat
    cat cat dog, and so on
    ((cat )*dog)
    One or more of the letter a
    followed by a space and the same number of the letter a, that is, a a, aa aa, aaa aaa, and so
    on
    (a+) \1
    For Match Pattern "This function is similar to the Search and Replace
    Pattern VI. The Match Pattern function gives you fewer options for matching
    strings but performs more quickly than the Match Regular Expression
    function. For example, the Match Pattern function does not support the
    parenthesis or vertical bar (|) characters.
    Characters to Find
    Regular Expression
    VOLTS
    VOLTS
    All uppercase and lowercase versions of volts, that is, VOLTS, Volts, volts, and so on
    [Vv][Oo][Ll][Tt][Ss]
    A space, a plus sign, or a minus sign
    [+-]
    A sequence of one or more digits
    [0-9]+
    Zero or more spaces
    \s* or * (that is, a space followed by an asterisk)
    One or more spaces, tabs, new lines, or carriage returns
    [\t \r \n \s]+
    One or more characters other than digits
    [~0-9]+
    The word Level only if it begins
    at the offset position in the string
    ^Level
    The word Volts only if it
    appears at the end of the string
    Volts$
    The longest string within parentheses
    The longest string within parentheses but not containing any
    parentheses within it
    ([~()]*)
    A left bracket
    A right bracket
    cat, dog, cot, dot, cog, and so on.
    [cd][ao][tg]
    Frustrating- but still managable.
    Jeff

  • Question about match regular expression

    Colleagues,
    Very stupid question. I would like to get substring between "..." symbols. For example, string 02 July from Explosion occurred on "02 July", 2008.
    How to do this with single Match Regular Expression?
    For example such expression ".*" will give me "02 July":
    But I would like to get it without " symbols!
    I tried this "[~"]*" and this "[~"].*", then read this and this , and all without success... But I'm sure it should be possible. Can you help me?
    Andrey.
    PS
    This regular expression should give exactly the same output as following construction:

    I'm only using 7.0 now, but you can do this with Scan from String...
    %[^"]"%[^"]"%[^"]
    Message Edited by Phillip Brooks on 07-02-2008 02:47 PM
    Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
    If you don't hate time zones, you're not a real programmer.
    "You are what you don't automate"
    Inplaceness is synonymous with insidiousness
    Attachments:
    NotPCRE.png ‏20 KB

  • Little help with this regular expression ?

    Greetings all,
    My string is like "P: A104, P105, K106" and I tried to split it using following regular expression ,but seems even though it returns 'true' as matched, it does not split the string.
    Finally what I want is String is array like {"P:","A104","P105","K106"}
    What seems to be the problem with my regular expression?
           String PAT1="[a-zA-Z]:\\s([a-zA-Z]\\d{1,}([,]\\s)?)*";
         String inp="P: A104, P105, K106";
         Pattern p=Pattern.compile(PAT1);
         System.out.println(p.matcher(inp).matches());
         String strs[]=inp.split(PAT1);
         for(String s:strs){
              System.out.println("part  "+s);
         }

    pankajjaiswal10 wrote:
    You can also use split(":|,")No, that will remove the colon and leave the whitespace intact. My understanding is that the OP wants to keep the colon and remove the commas and whitespace. I would use this: String[] strs = inp.split(",?\\s+");

  • Multi-line String - Match Regular Expression

    I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
    Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?  
    Solved!
    Go to Solution.
    Attachments:
    MultiLine Regular Expression.vi ‏22 KB

    aaronb wrote:
    I am trying to figure out the format of a regular expression in order to pull select lines out of a multi-line string and populate those lines as individual elements of a string array while using Match Regular Expression. The overall length of the multi-line string can vary as well as the text contained within the string. The string can contain letters, numbers, and special characters. I have attached an example VI. Within the example VI I only want to return the lines beginning with "Device #" into the array. The number of lines beginning with "Device #" can vary but I want to capture them all.
    Or is there a better function to use instead of Match Regular Expression that will give me the desired outcome?  
    Match Regular Expression works well for this.
    Ben64

  • Match Regular Expression Function input string format

    Hi,
    I am new to labview and was having some difficulties using the Match Regular Experssion Function.  
    I am using labview to communicate with a sensor.  I have installed the NI device driver to do so.  The output of my sensor is in the format, 
    X20
    R40 P20 A123.  The numbers in this case are arbitrary.  I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers.  I am having difficulties formatting the input string on the Match Regular Expression Function.  Could you please give me some tips on how to format the example I provided.  
    Thank

    MoAgha wrote:
    Hi,
    I am new to labview and was having some difficulties using the Match Regular Experssion Function.  
    I am using labview to communicate with a sensor.  I have installed the NI device driver to do so.  The output of my sensor is in the format, 
    X20
    R40 P20 A123.  The numbers in this case are arbitrary.  I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers.  I am having difficulties formatting the input string on the Match Regular Expression Function.  Could you please give me some tips on how to format the example I provided.  
    Thank
    Here is a way to do it if the format is constant (X R P A followed by a positive integer number).
    Ben64

  • HWIC-4ESW having same MAC address with fa0/0 from CISCO2811 router.

    Hi Expert, I Have a situation where a 2811 is configured with 2 VLANs from HWIC-4ESW module, different ports configured, however the VLAN interfaces have the same mac-address with fa0/0 which causes ARP poisoning problem. It that anyway to solve this problem?

    Hi Lee,
    My understanding is, this is expected behavior and is due to the hardware limitation of the HWIC-4ESW Module. And I think the HWIC-4ESW Module (at least from my lab testing) always takes the MAC Address of the first on board LAN Interface.
    Also, I am able to change the MAC Address of the first on board LAN Interface (Ex.Gig0/0) but I cannot change the MAC Address of the VLAN SVI.
    I hope it helps.
    Regards,
    Arul
    ** Please rate all helpful posts **

  • How to specify in the ISE mac-address with its description?

    Hello :-)
    I want to implement ISE 1.2.
    We have a database of mac-addresses and their description (for example the phone with the Mac address, John).
    When connecting the phone John to a wifi network, WLC checks its mac-address in the database and allows access.
    How to specify in the ISE Mac address with its description?
    In the endpoint settings in ISE 1.2 there is no description field. We have ISE1.2.1.198, vWLC 8.0.100, AIR-LAP1131, MS AD (Win2003).
    How can I handle this situation? Any ideas?

    This link http://www.cisco.com/c/en/us/td/docs/security/ise/1-2/user_guide/ise_user_guide/ise_man_network_devices.html about managing network devices(router,switch), not endpoints(phone, notebook).

  • Matching Regular Expressions in OBPM 10GR3

    Hi all,
    How do I match Regular expressions like" Wait For Response" in Strings using OBPM?
    Any idea?
    Is there any exact syntax?
    Because I tried doing this:-
    for( int i=0; i < testGroup.length(); i++)
         if(testGroup.reason.match(regexp : "Wait For Response"))
              logMessage("--Test Group Matched--");
    But it does not work..
    Any idea?

    String myVar = "has matching_char_set";
    if ( myVar.match(regexp : '/matching_char_set/') ) {
    logMessage("matched...yep");
    Try like this ..should work.
    Rgds,
    Biltu

  • IR filter using "matches regular expression"

    Hi,
    I am familiar with Perl regular expressions, but I'm having trouble using the IR filter by regular expression in Apex.
    For instance, I would like to search for dates of format 'MM/DD/YY' - can someone tell me how this would be done? I tried '[0-9](2)/[0-9](2)/[0-9](2)' and many other patterns to no avail.
    Also can you point me to a good thread for regular expressions in Apex?
    Thanks for any help.

    Hi,
    you can play around with oracle regular expressions at
    http://www.yocoya.com/apex/f?p=YOCOYA:REGEXP_HOME:0:
    It's an Apex application, albeit "seasoned", where you can build and test the regex and it will be 100% compatible as it runs natively, so it's not simulated on a different platform.
    Most likely the IR filter will make use of REGEXP_LIKE so you can pick that function from the menu.
    Flavio
    http://oraclequirks.blogspot.com
    http://www.yocoya.com

  • HT5211 My HP 2355 won't show up in AirPrint? I have it plugged in via USB and set it up on my Mac mini with the airport express network. Any advice?

    My HP 2355 won't show up in AirPrint? I have it plugged in via USB and set it up on my Mac mini with the airport express network. Any advice?

    Unless your HP printer is an AirPrint-ready device, just connecting it to the USB port of the AirPort Express base station will not make it so.
    On the other hand, connecting a non-AirPrint printer to the base station's USB port it can be shared out by the base station's print server. Please see the following Apple Support article for details.

Maybe you are looking for

  • Question about dates shown in finder

    I have a problem and need help. First question is: what date is shown in default finder settings on files? Creating date , Modified or added Date? on Mac, Windows? The problem lies here, I have to give clients JPEG picture files. we had to re-shoot (

  • How to get tamil font????

    i would like to read tamil ebook in my handheld but i found that my device is not supporting tamil fonts. I would like to know how to install fonts and where i can find them.

  • Can you create report and schedule in EVDRE

    Hi, I was asked by someone that if it is possible to create report and schedule in one single worksheet?  As you set report/schedule in workbook options for the file my assumption was its not possible. Is there any work around? Also i was asked about

  • Check table Harmonization Syncrhonization with R/3

    Hi all, Has anybody tried to synchronize the harmonized Check table data with R/3? I am designing central master mainteance scenario however not sure how to syncronize (not Syndicate, that's easy using MDM tool) check table data with R/3. e.g. If I c

  • Layer 2 connect - data center web hosting

    hi, i need your help!! i have data center with the nexus 7000 , i have servers connecting to the cisco 7000 with web servers. my company do hosting for customers. the poing that we have shared resources like vmwares on blades and so on.. mean that th