How can I use regular expression to match this rule

I have a String ,value is "<a>1</a><a>2</a><a>3</a>",and want to match other String like "<a>1</a><a>8</a>",if the one of the first string(like "<a>1</a>") will occur in the second string,then will return true.but I don't know how to write the regular expresstion.
Thx

Fine fine. :P
I was a little bored, so here's some code that uses Strings and a StringBuffer (though you could use a String in place of the StringBuffer). Is this perhaps better? :)
          String testMain = "<a>1</a><ab>2</ab><ab>3</ab>";
          String test = "<ab>1</ab><ab>3</ab>";
          String open = "<ab>";
          String close = "</ab>";
          StringBuffer search = new StringBuffer();
          String checkString = null;
          int lastCheck = 0;
          int start = 0;
          int finish = 0;
          boolean done = false;
          while (!done) {
               start = test.indexOf(open);
               finish = test.indexOf(close);
               if ((start == -1) || (finish == -1)) {
                    System.out.println("No more tags to search for.");
                    done = true;
               else {
                    checkString = test.substring((start + open.length()), finish);
                    search = new StringBuffer();
                    search.append(open);
                    search.append(checkString);
                    search.append(close);
                    if (testMain.indexOf(search.toString()) != -1) {
                         System.out.println("Found value: " + checkString);
                    test = test.substring(finish + close.length());
Resulting output:
Found value: 3
No more tags to search for.
-G

Similar Messages

  • How can I use regular expression to open files of certain types in java?

    Ok this is the problem I am facing:
    I have a command line input of something like "/usr/foo/bar/*.html"
    and there are multiple files in that folder that end with .html.
    How can I use the input to go through/open all the .html files in Java?
    Help would be greatly appreciated thanks!

    Or if you have to do it in java, check out the interfaces java.io.FileFilter and java.io.FileNameFilter
    http://home.tiscali.nl/~bmc88/java/sbook/0128.html
    class HTMLFilter implements FilenameFilter {
        public boolean accept(File dir, String name) {
            return (name.endsWith(".html"));
    }Cheers,
    evnafets

  • HT1515 How can I use Airport Express (1st generation) with OS X Mavricks?

    How can I use Airport Express (1st Generation) with OS X Mavericks?

    1st Generation AirPort Express will work fine with Mavericks.
    Are you sure that you have a 1st Gen Express?
    Check the model number on the side of the Express. 1st Gen is A1264.
    If you see A1084 or A1088, these are much older versions of the Express that were sold long before Apple began to use the Generation naming with "n" wireless devices in 2007.
    Mavericks will not support the A1084 or A1088. Use another Mac running Leopard, Snow Leopard, or a PC if you need to administer the older Express.

  • How can I use regular expresion to validate email adress

    how can I use regular expresion to validate email adress.

    var emailExp:RegExp = /([a-z0-9._-]+?)@([a-z0-9.-]+)\.([a-z]{2,4})/;

  • How can I use AirPort Express when traveling?

    How can I use AirPort Express when traveling?

    How can I use AirPort Express when traveling?
    Connect the AirPort Express to the Ethernet port in your room.....to be able to create your own private wireless network in your room for multiple devices.
    You will still have to pay the hotel Internet charge for one device, if the hotel charges for Internet access.
    If the hotel only provides wireless service, then a single AirPort Express will not help you.
    However, if you have two AirPort Express devices, then you can use one to "join" the hotel wireless network, then connect the second Express to the first using an Ethernet cable and create your own wireless network for multiple devices in your room.

  • How do i get a list of all Roles defubed under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?

     

    Sorry for the typographical mistake.
    Please read the question as:"How do i get a list of all Roles defined under a particular OrganizationalUnit? How can i use LDAPConnection.search method for this?"

  • Can I use regular expressions in Java 1.3

    Hi,
    Dose Java 1.3 suport regular expressions?
    How can I use it?
    Thanks.
    bevin ye

    The 1.3 core API doesn't support regular expressions. Hint: There's an item "Since:" in the JavaDoc of most classes that indicates the version it was initially available. If you look it up in the JavaDoc of java.util.regex.Pattern you'll notice that it's value is 1.4.
    But there are several third party libraries that implement regular expressions, 'though I've not used them extensivly, so I can't tell you which one's the most usefull.

  • How to form a regular expression for matching the xml tag?

    hi i wanted to find the and match the xml tag for that i required to write the regex.
    for exmple i have a string[] str={"<data>abc</data>"};
    i want this string has to be splitted like this <data>, abc and </data>. so that i can read the splitted string value.
    the above is for a small excercise but the tagname and value can be of combination of chars/digits/spl symbols like wise.
    so please help me to write the regular expression for the above requirement

    your suggestion is most appreciable if u can give the startup like how to do this. which parser is to be used and stuff like that

  • How to use regular expression replace for this special characters?

    hi,
    I need to replace the below string, but i couldnt able to do if we use the special charaters '+', '$' . can anyone suggest a way to do this?
    select REGEXP_REPLACE('jan + feb 2008','jan + feb 2008', 'feb',1,0,'i') from dual
    anwers should be :- feb

    you should use escape character \.
    the regular expression will look like as follows:
    select REGEXP_REPLACE('jan + feb 2008','jan \+ feb 2008', 'feb',1,0,'i') from dual
    hope this is what you needed.
    cheers,
    Davide

  • How can I use an Express database build with RAA in Express Objects???

    Hello, everybody!
    I have installed Express Server and Client on my computer. I've build an Express database With Relational Access Manager mapping data from an Oracle database.
    Now I want to use this express database in Oracle Express Objects.
    I understand that an express database build with understand can be used by defining a connection to Express Server and using the option Relational Access Manager Connection.
    But, I didn't understand the settings of this option. I open the settings window and there it is :
    - the MASTER DATABASE Box where I have to write the name of the CUBE from the express database build with understand?
    - the RDC File Box : what do I have to write here? I've read the HELP but I didn't understood. There is no file with the RDC extension in my computer.
    Thank you for your help!
    Anca.
    [email protected]

    you can extend it, very easly, with an Airport Express.
    once you connect the AExpress, on the App Airport Utility, in Wireless tab choose to "Extent a Network", you will be able to select your Network enter your Network Password and it is done
    i have 2 AExpress to extend my signal and also to Airplay to Remote Speakers and works perfectly
    good luck

  • How can I use airport express in India on my ipad

    I have iPad that I want to use in India with airport express. Please help how to.

    Connect the Airport Express via Ethernet cable to the modem you got from your Internet provider. Assuming your PC is using wired Internet now download the Airport utility. Then follow the quick setup guide that came with the AEX.

  • How can I add Regular Expression verify?

    I need to write a Regular Expression for date whose format is 'yyyy-mm-dd'('2004-5-3' or '2004-05-03') and a Regular Expression for phone number whoes format is '12345678' or '1234567' or '13809441234'.
    Thanks for any help.

    The date format is a little tricky as there are many invalid combinations. You'd be better off calling TO_DATE with your user input and format mask. If an error is returned, the date is invalid.
    For the phone number assuming a valid phone number could be 7, 8, or 11 digits (it's a little difficult to tell what the format your suggest is) then you could apply something like the following:
    ^[0-9]{7}([0-9]|[0-9]{4})?$
    Regards.

  • How can I use the onmouseover event in this case?

    Hello!
    Sorry If it's a simple question... I'm a beginner in JSFs :P...
    I need to do with a dataTable an effect.
    In my old JSP file (Basically made with HTML), when I made a TABLE, I changed the class of all the rows. Like this:
    <TABLE>
    <TR onmouseover="this.className='OnStyle'" onmouseout="this.className='OffStyle'">
    <TD>...</TD><TD></TD>
    </TR>
    </TABLE>All the row changes if the mouse was pointing at its.
    How can i do this with a simple dataTable? I have only 2 colums and a few rows :(
    Thanks a lot!

    Apparently JSF does not provide as simple solution to this simple task as one would expect. I've been looking for a solution to it myself but not found an answer.

  • How can I use Airport Express to create a standalone Wi-Fi network without Internet Access so I can browse web pages on the local network? I will be using MAMP as my server (Apache)

    I would like to create my own Wi-Fi standalone network at an upcoming tradeshow where there will be NO internet access.
    Currently, I run and develop sites on my iMac use MAMP to manage my sites locally. Using MAMP, I run my sites as though they are on the internet although everything is local.
    I purchased an Airport Express hoping I could create a standalone network so that the iMac would broadcast its website to whatever device connects to it such as my iPhone, iPad and MacBookPro.
    However, after setting up the network successfully (I have a green light on the Airport Express, and there is NO internet going through it), I  am  not able to go any further by logging into the iMac's websites from the other machines. Form my MacBookPro Finder, I can look at files and folders using afp://10.0.1.2, from the Find/Go/Connect to Server utility, but I can't browse the website that is running on the iMac via the Safari browser.
    Can anyone help me configure my MacBookPro (or iPad, or iPhone) to run the website on the iMac when they are all on the same network?
    Thanks so much!!

    1) connecting the TC using a ethernet cable from one of the two modem's LAN ports to the TC's WAN port
    2) create a new Wi-Fi network using the TC ?
    Does someone already create a new Wi-Fi network using its TC connected by Ethernet on a modem/router device ? How do you set up the DHCP (and NAT) ? Which range did you use ?
    This is easy enough to do..
    Plug the TC directly into a computer.. without other connections to do the setup.
    Using the newly installed 5.6 utility.
    Bridge the TC.
    Create a wireless network.
    This is an older screen shot and I would set security to WPA2 Personal only not WPA/WPA2 Personal as shown above.
    I do recommend you use wireless names that are short, no spaces, pure alphanumeric.
    Update the TC..
    Now plug it into the modem router.. it will be a part of the network without doing NAT and DHCP itself.. which you do not want.. that leads to double NAT issues.. but it is a WAP that provides access to devices on both 2.4ghz and 5ghz bands directly to the main router.

  • How can I use airport express to over-ride TWC wireless ubee?

    I currently pay Time Warner Cable $6 a month for the wireless feature of their regular internet service, administered via a ubee modem. I want to cancel this service and instead run my wifi through an Apple Airport Express. But when I plug it in and try to use it, it flashes amber (I gather I need to disable the TWC wifi first, but don't know how to do this and TWC are reluctant advisors.)
    Any help greatly appreciated.

    It is always a good idea to perform a complete power recycle of your networking equipment any time you make hardware configuration changes.
    Please try the following:
    Power-down the modem, AXn and computers; leave them powered-down for 10-15 minutes. Note: Power-down order is not critical.
    Power-up the modem; wait at least 10-15 minutes to allow it adequate time to initialize.
    Power-up the AXn; wait at least 5-10 minutes. Note: The AXn may continue to flash amber as it may still require some additional configuration changes (like enabling wireless security) before it will go solid green.
    Power-up your computers.
    Wireless clients, connected to the AXn, should now be able to access the Internet. Please post back your results.

Maybe you are looking for

  • In r12 What is use of Purge log and Closed system alerts

    Hi In r12 What is use Concurrent reqest "Purge logs and Closed system alerts " is there any diffrence with "Purge Concurrent Request and/or Manager Data Program" we have to purge cm logs and data. '

  • Connect MBP to Sony TV

    My MBP (MacBookPro5,4, Intel Core 2 Duo 2.53GHz) will not display when I connect it to my Sony TV. I am using the MiniDisplay to DVI adapter, then DVI to HDMI to my TV. The display shows up in the System Preferences, but nothing is displayed on the T

  • Monitor user access to planning

    Hi I am trying to find out Users login information in planning, who is accessd planning application at what time. Where can find this information From view statistics i can see only currently logged in users. Thanks,

  • How to get QaaWS query details?

    All, I am wondering if there is a way to "audit" any QaaWS actions. From what I know, the only way to look at any QaaWS queries is thru the QaawS tool that comes as part of the client install. Is there a way to access information on the web queries i

  • Can't open a .indd by double clicking in CC

    When I double click an .indd file in Windows Explorer InDesign won't open the file. I always have to open it from the File menu. I use Win8. Any help would be appreciated. Thanks