0
votes
2answers
25 views

Java 7 Unicode Regex Tabs only and Spaces only

I'm trying to create two Pattern matchers to detect tabs only and spaces only in a read file, regardless of language encoding. These will be used to determine what delimiter is used in a file, so they ...
-1
votes
1answer
52 views

Regex to match exactly numbers of chars [on hold]

I tried to find the answer to my problem in the questions history but can't find. So here is my problem. I have a list of string just like this: 1522800027011280060520140946181200900721 I solve ...
0
votes
0answers
15 views

Configure checkstyle method names for @Test methods only

Is it possible to define the checkstyle MethodName module in order to verify a diferent regex for @Test methods? My configuration now is: <module name="MethodName"> <property ...
-3
votes
3answers
28 views

Getting digits from string Regular Expression in Java [on hold]

Hi don't know much of regular expression and I am trying to get just the digits from the string "glm=4563125@", can someone please help me. The number of digits can vary, so it's not specific the ...
2
votes
3answers
33 views

java regex $ metacharacter

I am new to java regex.I saw this in Docs: $ The end of a line But when I try this snippet: String str = "firstline\r\nsecondline"; String regex = "$"; System.out.println(str.replaceAll(regex, ...
2
votes
3answers
41 views

What should be the result of boolean variable value for given regex match?

String HouseNo = "a"; boolean value = HouseNo.matches("[0-9]+[/\\-]??[A-Za-z]"); According to me, the value should be true but it comes out to be false. Can anyone explain why? Additionally I tried ...
0
votes
1answer
28 views

find out the domain from an emailId through regex in java

Suppose the email Id is [email protected] and i need to extract the domain name(i.e xyz) from this. I'm fully new in regex. By googled a little I find out a possible solution from this conversation . And ...
-7
votes
1answer
27 views

Regex patterns for AANNN and ANEE formats [on hold]

I need regex patterns for the AANNN and ANEE formats. A means letters N means digits E means either letters or digits. I need to validate input strings according to these formats. Examples ...
-5
votes
0answers
50 views

String.contains(searchText) doesn't work for more than one word

I have some content and I am trying to find if the some "searchText" exists in the content. When I look for a single word in the "searchText", the String.contains(searchText) returns true but returns ...
0
votes
0answers
22 views

jakarta-regexp-1.5.jar Library for RegEx issue [on hold]

I am using this library for RegEx in J2ME This Library is working perfectly fine for me if RegEx is enclosed between ^ and $. For eg. "^[0-9]+$" If RegEx in not enclosed between ^ and $ then it ...
1
vote
3answers
26 views

Insert a whitespace after comma, period and other punctuation marks

In Java, what is the best way to fix the missing whitespace after some punctuation marks like: , . ; : ? ! For example: String example = "This is!just an:example,of a string,that needs?to be ...
0
votes
5answers
46 views

Remove punctuation from string [duplicate]

I have a string and I need to remove these symbols: -- + [ ] { } ( ) \ / For example: String clean = "This \ is / an example. This -- is + an [(example)]."; clean = ...
0
votes
3answers
36 views

Regex not valid when trying to invalidate alpha's and non-zeros

Wrote a method which takes in a String and checks to see the follow conditions: If String is "quit", it will terminate the program. If the String is any value other than an integer, it should return ...
1
vote
0answers
42 views

Regex , mathematical equation matching [duplicate]

I am trying to make mathematical equations validation using regex in Java. So far I have something like this: (?:\\d+\\.)?\\d*([+\\-]?\\d+)? It looks ok, but I still have some problems, with ...
0
votes
1answer
51 views

How can I save a image file from a String in Java?

I need read a file, extract the bytes and add the <segment></segment> tag. Then I have to extract the bytes and extract what is between <segment> label. Finally, the tag data will be ...
0
votes
2answers
58 views

Parse a csv file using Regex in java with '|' as seperator

Can anyone help me with Regex ? I got an Java Program, that reads in .csv files to load it into a Database. Currently ist uses Pattern csvPattern = Pattern.compile("\\s*(\"[^\"]*\"|[^|]*)\\s*,?"); ...
0
votes
0answers
16 views

hadoop PathFilter notfound

Here is a simple Pathfilter i am using import org.apache.hadoop.fs.Path; import java.io.IOException; public class RegexExcludePath implements PathFilter { private final String regex; public ...
-1
votes
0answers
48 views

Regex: get min and max length of any string

I am looking for a way to find out the max and min lengt of a regular expression. For example I have ([A-Z]{1,3}[- ][A-Z]{1,2}[0-9]{1,4}) it is pretty easy because I know this code. min=4 max=10 ...
-1
votes
1answer
35 views

Regular expression help for href attribute check

I have the below regular expression check for href attribute which checks for protocol, sitename & domain. I need to add a check for "javascript:". Could someone help me on this? I am not able to ...
0
votes
3answers
63 views

Java string replace using regex

I have strings with values "Address Line1", "Address Line2" ... etc. I want to add a space if there is any numeric value in the string like "Address Line 1", "Address Line 2". I can do this using ...
0
votes
3answers
48 views

Regular expression matching issue with the following scenario

I am developing an application. User will enter some of the setting value in the server. When I ask for the value to the server through the inbuilt API. I am getting values like as a whole string: for ...
-1
votes
3answers
45 views

Writing Regex According to [ char

I have string something like this: 10:11:22 [UTP][ROX][ID:32424][APP STR] I want to seperate each them of. How can I do it with regex? I want to get seperately "10:11:22", "UTP", "ROX", ...
1
vote
6answers
50 views

Java replaceAll() to pull numbers and periods

I have a line of output similar to "Spec-Version: 11.3.0". I'm struggling to pull only the version out, with periods, using replaceAll(). Right now I have something like this: version = ...
-2
votes
2answers
36 views

Regex rewite input string in java

I have a input query string which I want to rewrite into below format. input : select sum(spend) from test where time = date_add('2008-12-31', 1) and product_name = 'test123'; rewritten : select ...
3
votes
6answers
108 views

Remove string between characters

I would like to remove everything(for the chars like {}$* \w+ "") which is between ; and #: For example I would like to remove from this string: Input: OR(AND(CA18*CB18);M10#;ABZZ/kld // remove ...
1
vote
4answers
65 views

Why is String.split behaving like this?

My code is public class Main { public static void main(String[] args) { String inputString = "#..#...##"; String[] abc = inputString.trim().split("#+"); for (int ...
0
votes
3answers
58 views

Java library to analyze String and extract numbers

I know that the title is quite vague but I'm gonna explain what I'm looking for. I have to analyze a lot of data from various sources and I'd like to check if a value can be interpreted as a numeric ...
0
votes
2answers
28 views

Regex for single or double-quote delimeter

I have wrote a regex for split a strings by double-qoutes: Pattern delimeter = Pattern.compile("\""); How could I extend it for working with BOTH single and double qoutes? I have tryied: ...
-1
votes
3answers
38 views

Regular expression for retrieving http:// from the given URL

I want to retrieve http:// or https:// as per the protocol being used from the given URL. How can i do it using Pattern and a Matcher? If there's some other way to do it then suggest me the ...
4
votes
2answers
54 views

Algorithm to compare a list of word String to a list of regular expression

I want to count the existence of words in textToBeTested array from expList. Note that both expList and textToBeTested arrays can very large. I can simply traverse both lists and use ".matches" ...
3
votes
5answers
48 views

Regex with grouping groups matches unintuitively?

I am a beginner trying to learn how to use regular expressions in Java. By going through a few online tutorials, I wrote the following sample codes to teach myself how regex with grouping operates, ...
3
votes
2answers
35 views

Java Regular Expression - Characters “(” and “)”Matches the Pattern “[\\p{Alpha} '-,.]”

I have been wondering why characters "(" and ")" matches the pattern "[\\p{Alpha} '-,.]". Please take a look at my code. The method matches will return true for the characters "(" and ")". Also, are ...
-6
votes
1answer
39 views

Regex - Negative Lookahead - Java [on hold]

I'm trying to write a simple regular expression that will reject a standalone '\' but will accept the '\' if followed by anything else. For example: the string '\aba asda \87hsm' would be accepted ...
0
votes
3answers
41 views

Split string of numbers into individual numbers

How could I split the numbers in the string "542" into individual digits? On my desktop I can split the numbers using String.split("") and it works fine. But when run on Android, I get a ...
-1
votes
2answers
28 views

How to replace all matched text with dynamic group?

If I got a String="#1 and #2", a Map={"1":"a", "2":"b"}, What I indend to do is to replace #x with the value evaluated from Map(x), whose result should be "a and b". My code is as follows: ...
0
votes
4answers
61 views

Request a Regular Expression

Here is my text as Entry : This is An Image File [LoadImage:'image1.jpg'] this is Another Image [LoadImage:'image2.jpg'] I need to get [LoadImage:'*'] start and end position(s) as an array in java
-2
votes
0answers
63 views

Finding primary class of java [duplicate]

Given a valid file that contains a valid Java source code that can successfully compile and execute. I need to find out the name of its primary class. A primary class name can be the class that is ...
1
vote
3answers
54 views

Regex pattern for multi-episode file names

I'm trying to write a regular expression to get data about TV show episodes from a file name. I'll start with showing a few examples of the kind of inputs I'm dealing with and how I'd like the data ...
0
votes
0answers
36 views

Regex pattern for obfuscated or compressed classes in jar file

I'm building a program that will take a jar file as input and determine the percentage of obfuscation applied to code. basically, I want to detect obfuscation at both package and class level using ...
0
votes
3answers
48 views

Java regex - combining expressions

I am trying to write code that returns a credit card vendor using regular expression, which seem to work, eg: // Visa - always begins digit 4, 13 or 16 digits long ^[4].{12}|^[4].{15} // Visa ...
0
votes
1answer
26 views

Image extension validator

I am new to regular extension, I am using following code to validate image extension, its giving me wrong output when I pass image name with space. Please provide me solution. public class Test { ...
1
vote
3answers
57 views

Wildcard matching in Java

I'm writing a simple debugging program that takes as input simple strings that can contain stars to indicate a wildcard match-any *.wav // matches <anything>.wav (*, a) // matches ...
-4
votes
0answers
32 views

consecutive numbers or consecutive identical characters in a string [duplicate]

To whoever closed my last question, this has not already been asked and answered by another question or user. I want to create a way to account for the following (two separate expressions): check ...
-1
votes
0answers
41 views

regex for consecutive numbers and identical characters [duplicate]

I want to create regex for the following (two separate regex expressions): check if string is entirely of consecutive numbers of more than 3 characters i.e. "123", "1234", "12345", "45678", ...
-1
votes
1answer
28 views

Parsing Java Classnames From Source File using Javascript

Given a source file (Java / Scala), how do I parse out the class name of the source file using Javascript? Specifically, user enters source code into a browser-based editor. I would like to parse ...
-1
votes
3answers
51 views

Java replace pattern

I need to replace the ROOMS start and end tag from an xml file. <A><ROOMS><B></B></ROOMS></A> becomes <A><B></B></A> And also ...
-1
votes
5answers
35 views

How to write a regular expression for extracting 2-3 letter Australian state abbreviation?

I need to extract the state data (NSW, SA) from the following strings: 55 Christie St, St Leonards NSW, Australia 338-340 Tapleys Hill Rd, Seaton SA, Australia Kincumber South NSW, Australia For ...
0
votes
2answers
55 views

Regular expression to match '\n' character

I am having a string "<?xml version=2.0><rss>Feed</rss>" I wrote a regex to match this string as "<?xml.*<rss.*</rss>" But if the input string contains \n like ...
0
votes
1answer
18 views

How to use quantifier regex pattern on blackberry ({m,n})

Hi im trying to write a validation class using : regexp-me lib because of the answer of this post. What did i do String id = "123456789"; String pattern = "\\d{7,8}"; public boolean ...
0
votes
3answers
40 views

How to return the first chunk of either numerics or letters from a string?

For example, if I had (-> means return): aBc123afa5 -> aBc 168dgFF9g -> 168 1GGGGG -> 1 How can I do this in Java? I assume it's something regex related but I'm not great with ...