tag « Match « Java Regex Q&A

Home
Java Regex Q&A
1.Development
2.find
3.group
4.Match
5.matcher
6.number
7.Operation
8.parse
9.Pattern
10.replace
11.validation
12.word
Java Regex Q&A » Match » tag 

1. How to change this regular expression to be case insenstive (looking for src tag)    stackoverflow.com

Regualar expression: <img[^>]+src\s*=\s*['"]([^'"]+)['"][^>]*>
This works fine when 'src' is in lowercase and manages both single and double quotes. I would like this expression to return matches for following test data
1. <html><img src ="kk.gif" ...

2. Java regex to retain specific closing tags    stackoverflow.com

I'm trying to write a regex to remove all but a handful of closing xml tags. The code seems simple enough:

String stringToParse = "<body><xml>some stuff</xml></body>";
Pattern pattern = Pattern.compile("</[^(a|em|li)]*?>");
Matcher matcher = pattern.matcher(stringToParse);
stringToParse = ...

3. need to clean malformed tags using regular expression    stackoverflow.com

Looking to find the appropriate regular expression for the following conditions: I need to clean certain tags within free flowing text. For example, within the text I have two important tags: ...

4. How to wrap "
" tag around whitespaces in a java String?    stackoverflow.com

Suppose I have a long java String , I need to wrap all whitespaces (length >=2) with <pre></pre> tag... , How to achieve that ? ex :

before :
String str = "<font color=\"#000000\">A ...

5. Closing open XML tags with regex    stackoverflow.com

Basically I want to do the same as here which is done in Python. I'd like to replace all self-closed elements to the long syntax. Example

    <iframe src="http://example.com/thing"/>
becomes
  ...

6. Read href inside anchor tag using Java    stackoverflow.com

I have an HTML snippet like this :

<a href="XXXXXXXXXXXXXXX" target="_blank" class="view_job_link">View or apply to job</a>
I want to read href value XXXXXXXXXX using Java. Point to note: I am reading the HTML file ...

7. regex to identify anchor tag which should not be nested    stackoverflow.com

From the html source I've to identify anchor tag which shouldn't be nested. For example:

<a href="http://www.abc.com">abc<a href="http://www.dbc.com">dbc</a>
From this on first match it should return
<a href="http://www.abc.com">abc
On subsequent find
<a href="http://www.dbc.com>dbc</a>
While finding it ...

8. Java Regex - exclude empty tags from xml    stackoverflow.com

let's say I have two xml strings: String logToSearch = "<abc><number>123456789012</number></abc>" String logToSearch2 = "<abc><number xsi:type=\"soapenc:string\" /></abc>" String logToSearch3 = "<abc><number /></abc>"; I need a pattern which finds the number tag if the tag contains ...

9. Cut
-Tags from String end
    stackoverflow.com

I am currently developing a Web-Application using Java EE where I'm using a Rich-Javascript-Editor (http://www.primefaces.org/showcase/ui/editor.jsf). As the user can easily add too many linebreaks that will be convertet to linebreak-tags, I ...

10. Regex to add tag before     stackoverflow.com

I need to write a util to add a tag before any

Test string points to <p><a href="http://www.acdevents.com/au2005/">Acd Event</a> with an image <a href="http://www.acdevents.com"><img src="image.jpg"></a>
This needs to be changed to ...

11. how can I trim
tags using regex in java?
    stackoverflow.com

String s="<br /><br /><br /><br /><br />hello world!<br /><br /><br />";
s=s.replaceAll("<br /><br />", "<br />");
System.out.println(s);
//result: <br /><br /><br />hello world!<br /><br />
I want to get <br />hello world!<br /> how to do? ...

12. regex splitting tags in the string    stackoverflow.com

I have following regex (<.*?>.*?</.*?>|[\w[-]]+)\p{Punct}* which works perfectly for most string with tags but if a tag is not preceded by space then it breaks the tag while finding a match. Please ...

13. Regular expression for getting HREF based on span tag    stackoverflow.com

Possible Duplicate:
Regular expression for getting HREF from footer
I want to get the HREF tag of a specific span tag. In Java what is the ...

14. Regular expression for PennTreeBank tags in Java    stackoverflow.com

Please consider some examples of PennTreeBank Tags:

ADJP -ADV ADVP -BNF CC CD -CLF -CLR -HLN PRP$ PR-P$ NP
Please consider an instance of my program execution.
Enter your regex: ^-{0,1}[A-Z]{1,6}-{0,1}[A-Z]{0,1}\${0,1}
Enter input string ...

15. regex between boundary tags    coderanch.com

I have a text file captured from a PL/SQL query. It contains 482 XML documents with identical structures. I'd like to merge these into a single document. The root element tag of each document is "". I'm looking for a regular expression that will match "[any number of characters here]". The expression should match each of the 482 documents and not ...

16. how to form a regular expression for matching the xml tag?    forums.oracle.com

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={"abc"}; i want this string has to be splitted like this , abc and . so that i can read the splitted string value. the above is for a small excercise but the tagname and value ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.