-1
votes
1answer
23 views

Regular expression does not match

I need to define a pattern for a string and find all matches of that in a sentence in java eclipse environment. This in my code: public static final String EXAMPLE_TEST = "MD_pos "; public static ...
0
votes
2answers
27 views

Regex to Split String is not working well for “[,,.\\s]” in Java

I hope to split a String into groups by"," or","(Chinese comma) or "." or any blank char(like white space or "\n"). I am new to regex. I write the below test case: String str2="word1 , ...
0
votes
0answers
40 views

Why does the java regex “Look-behind group” need an obvious maximum length?

I know that java regex "Look-behinbd group need an obvious maximum length. Therefore, the following regex won't be compiled correctly in java: "(?<=abc.*)(abc)" "(?<=abc.*?)(abc)" ...
1
vote
2answers
56 views

Java Best way to extract parts from a string

I have the following string; [Username [rank] -> me] message The characters of the rank, username, and message will vary each time. What is the best way I can break this into three separate ...
-1
votes
1answer
45 views

Java Replace All Regular Expression

I'm trying to write a replaceAll in java that can replace json to be inside of an array instead of a object, Here's an example of what I mean: test:[{\"asdf\":\"asasdd\"}] my goal is to replace ...
1
vote
1answer
26 views

Simplest way to create json file from structured raw file in Java?

example file, x1 x2 y1 y2 12 20 30 40 13 14 15 16 I want to create a json structure out of it like so, { "coordinates" : [ {"x1" : 12 , "x2" : 20 , "y1":30 , "y2":40}, ...
1
vote
4answers
35 views

JAVA - REGEX - Don't match only whitespaces

I'm trying to build a regular expression that doesn't allow only whitespaces, but, for example, does allow " aaaaa " " aaaaa" "aaaaaa " The string's lenght should be {1,150}. I'm ...
0
votes
4answers
56 views

Regex - trouble matching the pattern “(cmd: )”

I am having trouble getting my regex to match the pattern "(cmd: .*)". For example, I want to match "(cmd: cd $HOME)". Here is my regex : \(cmd:\s+.*\) The problem is, this will also match "(cmd: ...
0
votes
1answer
16 views

How could I ensure that Expect will match login prompt everytime?

I am working on a tool that uses telnet to login to a Nortel DMS switch. The switch is quite old and there is no API or anything to tap in order to login. So in order to pass login data to the system ...
2
votes
3answers
44 views

RegEx How to get everything after a /

I'm currently using http://www.regexr.com/ and the Strings I'm trying to parse through are in the format of 133a1d6a-f4fa-49ba-928d-0f4c943ce5d3/File-20140805-013806693.pdf. I'm trying to get only ...
1
vote
1answer
30 views

Is an IP address with an octet given by 4 or more zeros a valid IP address?

The top voted answer for validating IP addresses here (which is a regex, so automatically unfavourable) returns false if you give it an IP address with 4 or more zeros in a single octet. Note that ...
0
votes
1answer
26 views

Regex quantifiers and character classes

There are examples and descriptions of regex quantifiers in Java Tutorial. Greedy - eats full string then back off by one character and try again Regex: .*foo // greedy String to search: ...
0
votes
2answers
33 views

Getting the value of an input tag with a specific ID using regex

I have following html content part, and I want to get the value -7326630261683062897:1196341531039871985 from all http content. There is only one unique point that is id javax.faces.ViewState. ...
-1
votes
1answer
21 views

Extract filelocation from a sentence

Input is being read from console and stored in string, trying to make pattern to get file path along with filename.extension if not than just filename.extension (without path also works) Sample input ...
-6
votes
2answers
37 views

Verifying string using regular expression in java [on hold]

I want to verify a string using a regular expression in Java. However, I do not want to use the inbuilt matches function of the String class or any external API. How exactly do I proceed about it? ...
0
votes
2answers
46 views

Is there an elegant way of doing this using regex?

I need to do a search and replace of variable-like patterns that can occur one or more times within a string. I started out doing the following that works fine: String str1 = "Hello $$(var)"; String ...
3
votes
5answers
39 views

Extracting Floating Numbers From String Using Matcher and Pattern

Suppose String str="123 abc 123.4 256"; Matcher m = Pattern.compile("\\d+").matcher(scan); while (m.find()) { System.out.println(m.group(0)); } By Using this code i am getting output as: 123 ...
1
vote
4answers
35 views

Get substring according to occurrence, reg exp java

Good day everyone! I wonder if anyone could help me out. I have a string -2.100 CM 1.000 CM 1.025 CM The problem is getting the values before CM, e.g. -2.1, 1.0, 1.025 Pattern pattern = ...
2
votes
4answers
54 views

Priority in regex manipulating

I write some java code to split string into array of string. First, I split that string using regex pattern "\\,\\,|\\," and then I split using pattern "\\,|\\,\\,". Why there are difference between ...
0
votes
2answers
29 views

Java Replace Regex - replace consecutive tabs

"aaaa bbbb dddd ffff ".replace("\\t\\t", "\\tx\\t"); I want to insert an 'x' in between two consecutive tabs. I think i got the Java Regex pattern wrong. Could someone tell ...
-5
votes
2answers
88 views

How will it be fixed so that it can catch mentioned URL formats? [on hold]

URL detector in a string is what I am worked on. In the code, as you can see, pattern tries to find URL in the string. However, it cannot detect; www.website.com www.website.edu www.website.gov ...
0
votes
1answer
49 views

String.split() not working properly, Scanner not reading properly, something is wrong

I'm having no idea why the split command is not working for me, and the sc.nextLine(); command is also not reading properly my input, the program is outputting these: Menu: 1 - Sign up on service. ...
-3
votes
0answers
41 views

Regular expression..retrieve text and replace

I have an xml file like: <pre> <book category="CHILDREN"> <details title="Harry Potter" author="J K. Rowling"> </book> </pre> How can I use substring on ...
0
votes
2answers
40 views

using java to find and replace without markup

I'm fairly certain this is asked & answered, but I cant find an (that) answer, so I'll ask: I want to use javas regex to find and replace. There is no markup involved (no, "${ImMarkup!} in the ...
1
vote
1answer
34 views

java - RegEx replace all but

I've come across a problem with using Regular Expressions in Java. I'm trying to replace everything in a string that doesn't match my expression. Example: String string = "This is test string (1) of ...
0
votes
2answers
23 views

Regex in Jersey Path Annotation

I'm currently facing a simple idea with a API that looks like this: /users -> return a collection of users /users/1 -> return all data included in one user ...
0
votes
3answers
48 views

Extract date from a string [duplicate]

I would like to find date from java string.But i can not able to do this please help String : 01-02-2014 <2> Ineed output like :01-02-2014 My code: public String rejex(String idate){ String ...
0
votes
7answers
58 views

How to match substring that ends with comma or end of line?

I want to parse out all attributes from the LDAP distinguished name. The attribute starts with comman or the line begin, ends with comma or the line end. I've written the following: String ...
0
votes
3answers
22 views

Java RegEx Split Matches and include trailing chars

I'm after some help with a regex that I can't get to work correctly, I've used a few online tools to test the patterns but with little success. I need to split a string based on a pattern ...
1
vote
1answer
20 views

java Matcher returns the whole match

I have a regex to get quizid from a string like completed"<a target="_blank" href="/Quiz/Details/290"> . this is my code String regex = "href=\"[^\"]+Quiz+[^\"\\d]+(\\d+)\""; Pattern ...
0
votes
2answers
43 views

Regular expression help needed for parsing strings in any order

I need to parse the following string with a regular expression. I would like to parse this string with any spaces between the parameters, and parameters in a different order. The string allways starts ...
0
votes
2answers
40 views

Java - Get src value from xml

I have this string from a xml node: <p> <a href="http://www.windoctor.it/hardware/amd-serie-a10-7850k-3-7-ghz-4-core/"> <img align="left" hspace="5" width="100" ...
-2
votes
0answers
47 views

how to find from 1 to 50 text proior searched text and 1 to 50 text after the search text with regular expression in java? [on hold]

I'm trying to find any character 1 to 50 text proior searched text(if there is any) and 1 to 50 text after the search text (if there is any) with regular expression in java? Contrary to popular ...
3
votes
2answers
76 views

Why do I need two slashes in Java Regex to find a “+” symobl?

Just something I don't understand the full meaning behind. I understand that I need to escape any special meaning characters if I want to find them using regex. And I also read somewhere that you need ...
-6
votes
2answers
45 views

extract information from xml using regular expression

I need extract the author from the text using regex. Also, I need have the index of every tags and authors. I tried few parser, none of them can preserve the index correctly. So the only solution is ...
0
votes
4answers
35 views

Find string after last underscore before dot extension

I need to find 20140809T0000Z in this string: PREVIMER_F2-MARS3D-MENOR1200_20140809T0000Z.nc I tried the following to keep the string before the .nc: (?<=_)(.*)(?=.nc) I have the following ...
0
votes
2answers
44 views

Using java regular expression to extract author from xml

I understand that regex is not ideal for this task. But I couldn't use parser since I need preserve the OFFSET. So I have two questions here, one is about regex and other is to extract "author". If ...
0
votes
4answers
65 views

Splitting String with wildcard

I have a variable String which contains values i need and splitters. The problem is, the length of the string is variable and the type of splitters as well. They arrive through XML-file. A string ...
0
votes
4answers
65 views

Place a Whitespace before a sign (!?)

I did a little program which add a whitespace before those signs ! ?. I use a regex form but I think my regex doesn't work. My code try { BufferedReader buff = new BufferedReader(new ...
0
votes
2answers
71 views

Java RegExp pattern for (

I am trying to form the Regular expressions for the string Duo Eyeshadow, COMPACT(LID/BASE FRAME ASSY) Java: Pattern p = Pattern.compile("\"[a-zA-Z0-9 &/.\\-{()}]+[,][ ...
-1
votes
2answers
26 views

Taking parts of a sentence in String using Regex

I have this sentences which I want to manipulate and take its information: Hello. Yr data allocation based on Fair Usage Policy is 10,240.0MB. Yr current usage is 2,858.6MB. Balance: ...
0
votes
2answers
42 views

How to get the String including white spaces [duplicate]

I am using a pattern \s\s\s\s(.*) on a String "      XYX XYQ WQHY   ". So after using this pattern on this string the white spaces are trimmed.exactly ...
-4
votes
0answers
39 views

How to read xml document with regex in java [duplicate]

I want to read xml document with regex in java. I want to get outside a changeable menu xml code and read tags and contets. After that, I want to assign to a 2D array the tags and contetns. Such as ...
1
vote
4answers
94 views

Java regex to extract fields with or without quotes

I am trying to extract key-value pairs from a long string in two basic forms, one with and one without quotes, like ... a="First Field" b=SecondField ... using the Java regular expression ...
0
votes
1answer
30 views

digit regex no match

I keep getting an error that I shouldn't be getting and I am no regex expert but it should be so simple. I looked over it so many times and can't figure out why it isn't working. I have also searched ...
1
vote
2answers
22 views

Struts 2: How to handle indexed-property buttons on a form

I need to implement a table where each row has editable information that the user expects to submit as a whole yet buttons on each row to delete that row immediately. Because I care about the form as ...
1
vote
1answer
27 views

Java Regex group matches spaces

I have this regex and my output seems to be matching each single space but the capturing group is only alpha chars. I must be missing something. String regexstring = new String("1234567 ...
4
votes
3answers
56 views

Java Regex: Matching a string between 2 colons

I'm trying to write a Java regex that will find all the strings between 2 :. If the string between the characters has whitespaces, line endings or tabs, it should be ignored. Empty strings are also ...
0
votes
1answer
29 views

Coloring regex word patterns in JTextPane cannot color trailing delimiter

I am almost there thanks to the good people on this list. I just need to please have help with the last bit. I have a JTextPane where I match certain word patterns and change their color to red. Any ...
0
votes
4answers
34 views

Regex to match expression with certain number/pattern of slashes

It's probably easiest if I just give examples... I have input data that looks like this: /foo/blah/something/this And some that looks like this: /foo/blah/this I need a regex that will match ...