0
votes
1answer
35 views

Split by regex with no particular range

im facing a problem regarding parsing of this text. I want to split it by unique account#. see below: Account#: 1 Data1 Data2 Data3 Account#: 1 Data4 Data5 Data6 Account#: 1 ...
1
vote
1answer
58 views

Replace all instances in string with unique replacement

I'm attempting to replace all instances of a particular String with a unique replacement. What I would like: If I have this String: String testScript = "while(true) { } while (10 < 7) { } ...
0
votes
5answers
42 views

timestamp string split to get date and time effective way

1) using regular expressions, patterns 2) using split function in String class I tried using split function i think its not a good coding practice. splitted input string using '_' iterate array like ...
0
votes
2answers
45 views

regex for simple mobile number(Scala Style)

simply i want a regex in scala style for mobile number. ex:- +9198989898989 +11234545745892 the total digits including + can be from 6 to 18(i think all valid number lies in between of it) if ...
3
votes
2answers
33 views

Trimming trailing whitespace from every line in a multi-line string using replaceAll

Please explain why in this expression, the replacement only occurs once, at the end of the string. "1 \n3 \n5 ".replaceAll(" +$", "x") // => "1 \n3 \n5x" According to the Java 7 docs for ...
0
votes
2answers
28 views

Java split and throw away on repeated char using regex

I'm really struggling with regex right now... I've read up and looked at a lot of examples, but cannot seem to find the answer. I'd like to split a string when the string "::" is found, and I would ...
-1
votes
3answers
70 views

What is the meaning of (?!^)

I am trying to learn regular expressions and got confused i saw this post java split () method so i have some questions regarding to the 2nd answer by Achintya Jha; 1) why does str2.split("") ; ...
2
votes
4answers
43 views

Error when parsing string to ignore whitespace, Calculator class

I'm learning Java and I've been coding a calculator class. For now, it is only designed to do simple operations with two numbers, e.g. 2 + 2. Here is a small section of my code: public static void ...
0
votes
0answers
28 views

Why must Regex escapes be escaped? [duplicate]

Getting down and dirty with the regex implementation in Java, I spent a good two hours today troubleshooting a regex that was supposed to match consecutive whitespaces, but didn't. After googling and ...
-4
votes
1answer
32 views

REGEX with two capturing groups

I need some help for a regular expression: I have this example code in regex101: http://regex101.com/r/iW8hP4/4 dsgssgdfgdsfg <result1>A1<result1> anythingiwith<>and"234and ...
0
votes
1answer
33 views

Porting a regular expression to a more restrictive regular expression implementation that does not support conditional references

I have an answer to another question I asked that doesn't work with Java because it doesn't support the conditional reference feature. Since there is an answer that is correct in the general sense of ...
-3
votes
1answer
38 views

How to separate special string in android

I need to Bold and italic where is start of the special character in the sentence(only @,#). @ --> bold and italic # --> bold Example: Google Plus style #ListViews are all the rage these ...
0
votes
3answers
28 views

Java String Regex split and capture splitted portion

Following is the string, Card 41: Slot Type : SFC Card 42: Slot Type : PFC Card 43: Slot Type : GFC Operational State : Empty Card 44: Slot ...
0
votes
2answers
44 views

Replace a full stop period \\. with space \\. space

I want to separate a full stop period if it looks like a full stop period. The first issue I have solved and that is: // space period if followed by Capital letter having spaces before or not. ...
34
votes
8answers
2k views

Confusing output from String.split

I do not understand the output of this code: public class StringDemo{ public static void main(String args[]) { String blank = ""; String comma = ...
0
votes
2answers
42 views

Best way to store words for given scenerio

I am working on Java project [Maven]. I am confused in one point. I don't know what is logiclaly corect. Problem is as follows :- Sentence is given, and from their I have extract some particular ...
1
vote
3answers
58 views

How would I go about splitting a sentence in Java [duplicate]

I am attempting to split a sentence that is being printed to the console in order to avoid cut offs like so @ 80 chars: Welcome to fancy! A text based rpg. Perhaps you could tell us your name brave ...
0
votes
1answer
14 views

Use regexes in AOP poincuts?

I'm starting on AOP. I want execute beforeStart() before each method of MainMenuActivity class that start with "start". Something like this: @Before("call(void " + packaging + ...
2
votes
3answers
47 views

Custom Regex Replacement in Java

I want to find all patterns in a string that match the regex: no="(\d+)" then replace the digits in the group with something else. In the method below I can find and replace the entire match, but ...
0
votes
2answers
47 views

Replacing hard coded string with String variable which has slashes

I have the following code where i tried to replace the dump path by the variable "dumppath" which has same exact characters as in the string which i have in the command but when I replace it by the ...
0
votes
1answer
42 views

Regex to get string within double quote and inside bracket

This is my string test : [{"orange":["1.00","5"]},{"apple":["2.00","5"]},{"grapes":["3.00","5"]}] how can i get the string with in double quotes,splitted by every two brackets{}, i want to have ...
1
vote
2answers
72 views

Java replaceAll() occurences except some words

I have regex: str.replaceAll("(?!<img\ssrc=".*?">)([a-z])", ""); ...which should to kick all letters out except <img> tag body from this string: qwerty <img src="image.jpg"> zxc ...
0
votes
2answers
58 views

Find a string in a very large formatted text file in java

Here is the thing: I have a really big text file and it has a format like this: 0007476|000011434982|00249626000|R|2008-01-11 00:00:00|9999-12-31 23:59:59|000019.99 ...
4
votes
1answer
49 views

Interesting Java regexp limitation

I have tried the same expression in Python and it seems to be okay here, while Java fails with a stack overflow. This is the simplified test case to demonstrate the problem: // 10k whitespace. ...
0
votes
1answer
33 views

Regex and Date pattern matching

Below is the regex I am have: Pattern ddpat = Pattern.compile( "(\\d{1,2}/\\d{1,2}/\\d{4})" ); For an invalid date pattern 02/29/1975 (Since it is not a leap year), when I try the above REGEX on ...
-6
votes
0answers
39 views

regular expression of comma separated string in java [on hold]

Say we have a String s. I am now trying to use s.match(regex) to check if s matches the regular expression of word1 word2,word3,$100 word1, word2 and word3 are words without space it can be any ...
-5
votes
2answers
60 views

String Regex in Java - Puzzle [on hold]

I have the below String which contains multiple dates; something like this: I was born on 8/11/1965. I need to change all the dates into a different format. What is the best optimized way to achieve ...
3
votes
4answers
50 views

Regular Expressions, trying to match no more than one period?

Using: http://www.regexplanet.com/advanced/java/index.html and testing the regular expression(s): \.{0,1} (?=.*?\.{0,1}) I was referencing this: http://www.rexegg.com/regex-lookarounds.html, ...
-1
votes
3answers
78 views

How should I deal with space character when using split

So apparently when I am using S.split(" ") and I have " " (space) in my code file, it gets ignored. I was wondering if there's a way to overcome that. What I had in mind and is written in the ...
3
votes
1answer
60 views

Match anything before a certain pattern

I have string that can contain almost any character including (_- % and so forth. The string ends with (\d{1,2}). Eg. parenthesis with 1 or 2 digits. I now want 2 capturing groups, the 2 digits and ...
1
vote
2answers
70 views

java code for regex of email validation [duplicate]

I tried to simulate email validation without regular expression in java and wrote this code. I need help to improve efficiency of this code (or give me a better way to solve this issue please) ...
3
votes
4answers
59 views

Extract data inside nested braces

I want to extract content between the first nested braces and second nested braces separately. Now I am totally stuck with this can anyone help me. My file read.txt contains the below data . I just ...
1
vote
4answers
59 views

How can I remove characters around words?

I need to remove all characters that are not alphabetical from the beginning and end of each word. For example: --Hello& World-@ 1234... Should look like: Hello World 1234 I ...
0
votes
4answers
69 views

java string.split() issue

While solving a UVa question, I got this String and I need to split it an array of String removing # and @ Brazil#2@1#Scotland I was getting a ArrayOutOfBounds exception when I used, ...
1
vote
2answers
50 views

get the partial match string using java regex pattern

I have a pattern like below Sentence = "@502348@502002662[000861@10"; Pattern = "^@(\\d{6})@*(\\d{9})\\[(\\d{6})@(\\d{2})"; Matcher regexMatcher = regexPattern.matcher(Sentence); if ...
3
votes
4answers
49 views

Java RegEx - special character til end of string

Given rules for Strings are [Random Nr of Letters]##[Random Nr of Letters]#[Random Nr of Letters]########## String Length has to be 35 My String e.g. looks like ...
0
votes
1answer
30 views

Using regex in verifyEquals()

I have selenium test written in java, I want to use regular expression in verifyEquals() to match with selenium.getText(id="something") can I use it like this? verifyEquals("regexp: Regular ...
-3
votes
1answer
51 views

Regular expression in java for parsing classname from fully qualified name

Can anybody help me in parsing classname from fully qulaified name using regular expression in java. String to parse like this : "com.xxx.xxx.ClassName 0.0.2 i have to get className using Pattern ...
1
vote
7answers
73 views

Java regex to parse a string with special chars and numbers

I need a java regex to split the words from the following pattern. The sentence will start with @ symbol and continue with 6 numerals and then @ symbol. Then 9 numerals and then [ symbol Then 6 ...
0
votes
5answers
48 views

Find a regular expression not preceded by and not followed by

I'm trying to find the right regular expression, but nothing works exactly as I expect. In Java I'm using the String's function split(String regex). I have a list of strings (which are in fact names ...
0
votes
3answers
25 views

How to filter JTable with AbstractDataModel?

i am new to this site and i need help with something i can't solve on my own. I already scanned tons of forums and spent heaps of hours trying to solve it but nothing seems to work properly. So heres ...
0
votes
1answer
44 views

Java regex data modification

I'm working on an automated data identification program. The program is supposed to read through a text file and modify certain lines. For a simplified example, if a directory is ...
0
votes
4answers
48 views

Trying to pull out certain numbers from a string [on hold]

I have a string of numbers which looks like this ["100000100685716-2","603834770-2", "604544970-3"] can someone help me with a regular expression to match each long (first number before the "-") ...
-1
votes
3answers
35 views

Is there a way to specify using regex to show results not containing specific text [duplicate]

Is there a way to specify using regex to show results not containing specific text.Something similar to Select * from table where id not in {3,4,6};
1
vote
1answer
41 views

java regex to not get string not ending with dot [duplicate]

I m trying regex to get the strings starting with @ and not ending with a dot(.) For that i tried the java code(link here) but this does not show any results - @(\\w+)*(?<!.(.))*$ The ...
-2
votes
3answers
36 views

Regular expression that checks if characters are escaped [on hold]

I want to create the following rule in java: if a string contains a < or > the character before must be a \ (like checking if < and > are escaped). Can anyone tell me a regular expression that ...
1
vote
3answers
47 views

Java simple regex with hyphen

I'm trying to do something seemingly simple. I have meta-data with this format -key=value I've already split the string at the = but I need to take the - off. I'm trying to use this function ...
1
vote
1answer
32 views

Use Regular Expressions in JPA CriteriaBuilder

I'm using the JPA CriteriaBuilder to select entities of type MyEntity from a MySQL db as follows: String regExp = "(abc|def)" CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery query = ...
1
vote
3answers
33 views

Regular expression to extract (only) the first numeric value

How could I get only the first number from the strings below? Regular expression should stop at space or first non-numeric character. Examples: 6x2mL 7 x 5mL 100Subunits 2*5Kg
2
votes
1answer
20 views

how to get only particular fields in response in struts2

I have an action class in which many action methods are defined and appropriate getters and setters methods are also defined. I have some action methods from which I get the data as json by calling ...