Tagged Questions
2
votes
1answer
14 views
Struts 2 JSON interceptor for Custom Maps
I have following POJO's
public class Category {
private Integer id;
private String title;
private String description;
//many more attributes below
}
public class User {
...
4
votes
2answers
60 views
Java regex pattern matching (Irish car registration)
Sorry if this a dumb question but it's been driving me mental for the past 5 days.
I'm trying to make a regex pattern to match the Irish car registration example '12-W-1234'
So far this is what I ...
0
votes
2answers
39 views
Regex to remove stop-words between two words
I have a set of words named "stopwords". Now i need to match two words but between these words can appear a space or a words in the set "stopwords",for e.g. "power energy", "power of energy", "power ...
6
votes
2answers
92 views
Java regular expression to split string
I've been trying to build a pattern in Java to split the following string by dashes AND by tab characters. The exception is that if a dash appears after a number but before a tab space, in which case ...
3
votes
1answer
44 views
parse the specific string into desired output
I have 2 case as mention in main method.
*In case 1 * match method is returning the exactly what i want but
In case 2 its returning empty list.
please help me to give a common regex which can work ...
-1
votes
2answers
49 views
How to get key and value from a string [on hold]
I have a question about how to write a regex expression to get the key and value pairs from below string?
{"ReturnCode":"0","ErrorMsg":"success","EncryToken":"@@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
...
0
votes
0answers
15 views
Regular Expression for Enhance logic around effective and expiration date to auto-correct the year [on hold]
Sometimes.. the effective date year can be misread.. but it could be corrected by simply setting it to the lowest year that would make the date be in the future.
For example, if the date is read as ...
1
vote
3answers
43 views
Java regex finds only last match when I want all
I have this
Pattern pattern = Pattern.compile(".*(MyFunc[(](?s).*[)];).*", Pattern.DOTALL | Pattern.MULTILINE);
I want to match all the occurances of MyFunc(ANYTHING); .
while (matcher.find()) {
...
0
votes
2answers
40 views
Regex for validating EditText in Android
I'm trying to validate a TextView so that it can only contain alphabets and .
So far what I've done are it does not allow spaces and it cannot be left blank, so how do I carry on with not allowing ...
0
votes
3answers
32 views
Best way of extracting data from project
I've made this so far
import java.io.File;
import java.io.FileInputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
public class Test {
...
1
vote
3answers
46 views
Regex grouping and optional matches
Firstly: I'm not strong with regex. Now, that's on the table.
I am working on building a regex that uses groups, and optional components. The issue I have, is that I need to match a certain number ...
0
votes
0answers
20 views
Jackson json annotation for defining a regex
I created a data transfer object class (MyClassDto).
How can I check that the user_name key-value from the json matches
a certain regular expression? (and if not, it will throw an exception or ...
0
votes
4answers
62 views
Checking if string starts with _ or a number (0-9)
My code parses an XML file to look for IDs. But I only need to store the ones starting with _ or some number.
Node legacyNode = (Node) xPath2.evaluate(elem, XPathConstants.NODE);
Element legacyElem = ...
0
votes
5answers
53 views
Regex match two words
I'm using Java regex and I need to match two words, but between these words can appear a space or another word,for e.g. "power energy", "power of energy", "power for energy". I have to obtain all ...
0
votes
0answers
23 views
Is there a utility for reading a file as a list of custom beans?
I know that there are easy ways of binding for example an XML file to a bean. In contrast to that, I am looking for a library that allows me to specify some regex for parsing an entire file. I am ...
0
votes
1answer
20 views
Jersey REST And PathParam Regular Expressions
I'm trying to use Jersey to develop a REST web service. My requirement is for me to be able to access the web service and return data, based on the passed PatParam parameters. My web service so far ...
0
votes
2answers
45 views
Java regular expression for decimal ranges separated by a delimiter [on hold]
I have a input field that I want to validate.This input is used to describe a range. The input can take values of the form x-y or x,y . x and y can be decimal numbers like 101.22-135.33 or ...
8
votes
1answer
85 views
Finding strings with consecutive characters in Java
Write a function in Java which takes an Array of strings and from the array of strings returns only those strings which have a consecutive repetition of a particular letter for eg: if I/P is
...
0
votes
4answers
62 views
Remove double quotes from line
I have a string that looks like this
"He said, ""What?"""
In the entire file, there's actually more lines like that, separated by commas. The output of that line should look something like this:
...
1
vote
3answers
42 views
Can I avoid using regular expression to find even integer values from an int array?
To begin with I do not write code in java on a daily basis, though I am somewhat familar with most aspects.
I have an integer array with mulitple values present. I then take this array and convert ...
0
votes
0answers
37 views
Regular expression for month pattern date
My task is to find the dates from resume(txt file) and calculate the duration between them
I have crated the regular expression for the duration (date) pattern like
Jan 2012 - present or Jan 2012 - ...
1
vote
3answers
44 views
Is it possible to find value of dynamic groups using Java regexp?
If I have the text like
"Record with text1 Record with text2 Record with text3"
and I know: number of Records will be from 2 to 10,
is it possible to use regexp?:
...
0
votes
3answers
51 views
I can't get the first group of regex pattern in java
I'm trying to get the first group of a regex pattern.
I got this string from a lyric text:
[01:34][01:36]Blablablahh nanana
I'm this regex pattern to extract [01:34],[03:36] and the text.
Pattern ...
1
vote
2answers
35 views
How to regExp 'zero or one' groups which contain '.*'
I'm trying to get record1, record2, record3 from text:
"Record1 ANY TEXT 123 4 5 Record2 ANOTHER TEXT 90-8098 Record3 MORE TEXT ASD 123"
Each record appears ONE or ZERO times.
I use pattern:
...
0
votes
1answer
32 views
java regular Expression, fetching time out of a string
I am new to regex in java..
i have a string "2:05pm - 2:40 pm"
i need to get "2:05pm" and "2:40 pm" out from the single string using regex
I am using the follow regex expression, but I am getting ...
0
votes
1answer
15 views
Regex circle-dependency
I have got a problem while designing my scripting language.
We have expressions:
1 + 2
x
a := b + c
... etc
function call can contain expressions:
myfunc(1 + 2 + 3, b)
and expression can ...
1
vote
3answers
75 views
Java RegEx replace all characters in string except for a word
I am using the code in Java:
String word = "hithere";
String str = "123hithere12345hi";
output(str.replaceAll("(?!"+word+")", "x"));
However, rather than outputting: xxxhitherexxxxxxx like I want ...
1
vote
3answers
44 views
Java regex of string
I want to parse strings to get fields from them. The format of the string (which come from a dataset) is as so (the -> represents a tab, and the * represents a space):
...
0
votes
2answers
46 views
How to create regex that matches only not spaces and not letters?
I have String but very long.
I need to remove all not white spaces and all not letters :
My pattern is :
String content=readUrl();
content.replaceAll("(\\S)|(^\\[a-z])", "");
And this doesn't ...
1
vote
2answers
32 views
java regex expression, everything other than letter characters/strings
I'm writing a hashTable program. I only need to hash values that are either words, or single characters. I will define a word as anything that doesn't have a space or punctuation, and a character is ...
1
vote
5answers
59 views
How to spot * in regular expressions?
I want to spot and delete all lines that have *** in them. How can I do this?
I tried to use regex but got
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta ...
0
votes
1answer
22 views
How to force certain strings start with a new line using Java regex?
Here is the String details
String details;
System.out.println(details); // gives the following :
"Address: 100 Main Street
City: ...
1
vote
1answer
31 views
How to remove all lines that start with a certain string using java regex?
There is a text of about 1000 characters.
String text = "bla bla..................
.........................
.........................
...
2
votes
5answers
39 views
Splitting String by Regex
I've got this string here: M412 Rex | -HEADSHOT-. I want to split it on the | to get the first name, however my code is not working as intended.
System.out.println("weaponPart = " + ...
0
votes
3answers
37 views
How to match two or more spaces in java.util.Scanner?
I have row of numbers which should be splitted by space.
But space might be long or short or just single space.
I fail to write regex that would split numbers correctly . Here is my attempt:
public ...
-2
votes
1answer
35 views
Simple Regex freeze app [on hold]
I want to check whether a text contains phone numbers or domains. Previously, I remove all spaces. If there are no hits the app freezes. Why?
String aboutText = about.getText().toString();
String ...
0
votes
2answers
27 views
Grouping with OR in regex
The below is my regex pattern. I am using this to validate an email address.
^[\\w]+(\\.|\\_)?[\\w]+\\@{1}[\\w]+\\.{1}(([A-Za-z]+)|(\\.{1}[A-Za-z]+))$
The email ID must follow the following rules .
...
0
votes
1answer
50 views
How to get the src url and a href html
I've this piece of html code. I want to replace the link placeholders for the content mentioned in three separate attributes. This is what I've tried so far:
String texto2 = "url(\"primeiro ...
-7
votes
1answer
33 views
How to extract the numbers and texts from a string? [on hold]
i have a string like TEST_SAFA101 from which i have to extrat TEST_SAFA and 101 ... I have to increment the number 101 and store it as TEST_SAFA102 in a string..
0
votes
2answers
60 views
How to parse numerical values from a string?
How do I convert String in form xx:yy into integer form xxyy or float form xx.yy
For example If I have the following string.
String x = "10:30"
How do I get integer 1030 or float value 10.30 ?
1
vote
2answers
47 views
java regex match a string
Here is a string
* '''A happy man is too satisfied with the present to dwell too much on the future.'''
** "My Future Plans" an essay written at age 17 for school exam (18 September ...
1
vote
2answers
25 views
Java, extract paragraphs that match a given pattern from file, regex
I have a huge text file which contains around 5000 comments in this form:
D123456\tPOS/NEG\n Multiple lines of text go here. \n
D654321\tPOS/NEG\n Multiple lines of text go here. \n
...and so ...
0
votes
0answers
36 views
Splitting skips half a content when splitting by @
I have an android application that requests data from a text file. when I try to separate the data and initialize classes, I have serious trouble because half the data after splitting is missing. The ...
-4
votes
1answer
46 views
java changes String during processing?
i have to parse two large text-files. Each file contains a String-Mapping from a local-identifier to a String-value. The local-identifier is in fact just a temporary key. Later the mapping should be ...
1
vote
2answers
40 views
How to match any digits in front of a certain character?
I'd like to match all digits that are in front of the character K and extract that value.
In the example CARRY18K it would match the 18.
Probably I can only achive this with regex, but how?
Is \d+K ...
1
vote
2answers
40 views
Java swing JTable RowFilter ignoring symbols
Here is my code for filtering the JTable. 'text' is the input text to search in the table.
getSorter().setRowFilter(RowFilter.regexFilter("(?i)" + Pattern.quote(text)));
Here the filtering is case ...
-1
votes
0answers
60 views
Regex to validate logical expression [on hold]
I would like to use regex to validate a string that is supposed to be a logical expression with following possible words and operators:(,),AND,OR,Exxxxx (means E plus 5 digits). So valid expressions ...
0
votes
4answers
38 views
How to extract particular String pattern from a given text using Regular Expressions
I have following text.
emailString = "Jhon, N, Edward, <[email protected]>, " +
"Mickal, Lantz, <[email protected]>, " +
"Thomas, F, Kevin, <[email protected]>, " +
...
0
votes
3answers
39 views
pattern matching to detect special characters in a word
I am trying to identify any special characters ('?', '.', ',') at the end of a string in java. Here is what I wrote:
public static void main(String[] args) {
Pattern pattern = ...
1
vote
2answers
37 views
Regex for LaTeX umlaut escapes?
I am writing a Scala script which gets information from several sources, including a BibTeX file. Using the jbibtex library to parse the file.
My BibTeX source file contains LaTeX style escapes for ...