Tagged Questions
0
votes
3answers
40 views
Replace all special character except one
string = str.replaceAll("\\W", " ")
This replace all special character by " " (space).
But I try to exclude dash "-" as special character.
This my try:
string = str.replaceAll("\\W[^-]", " ")
...
-5
votes
1answer
65 views
a word should not start with a digit in Java
The string should meet the requirements:
1.it consist of some words separated by spaces.
2.only allow letters,digits,underscores, ' and " in each word
3.each ...
-8
votes
2answers
45 views
Regex to get all content of <> [closed]
I have raw string look like this <user1><user2><user3>...more users what Pattern.compile , should i use to print result like below...
user1
user2
user3
....
1
vote
2answers
43 views
Java regular expression: extract filename not working
I have a list of URL like this one:
http://mysite.es/img/p/3/6/2/5/6/36256.jpg
I need to replace the 36256 part.
My regular expression looks like this:
Boolean find = ...
-6
votes
2answers
58 views
Regex for methods in java
I need a regex for methods in java according to these rules:
no private/public or any of these
only void method (no returning methods)
Method names must start with a letter but may contain "_" or ...
0
votes
1answer
81 views
Java Regex Match fails
I'm new to Java, and have been trying to write a regex to capture 2 elements from a string in the form :
{ filename }{ lineOfChars }.
This is what I came up with :
import ...
2
votes
1answer
27 views
Highlight text In TextView which might contains HTML tags
I want to make an application about regex. User input a regex and a test text, and I want to highlight everything in the test text that matches the regex. Now I've made something like this:
// ...
1
vote
3answers
77 views
Couldn't remove a single quotes from a string?
This is my string:
String str = "CREATE TABLE `patiant` ( `ID` varchar(45) NOT NULL, `PATIANT_NAME`...";
I tried using replace and replaceAll methods but didn't work.
Here you can see what I'v ...
1
vote
2answers
81 views
How to divide string using regex
I have String like this:
String s = "1234567890";
I'd like use split("regex") to get this output:
12
23
34
45
56
67
78
89
90
What regex should I use?
1
vote
2answers
65 views
Regular expression with String.split() [duplicate]
How can I implement regular expression to String.split() to seperate values by spaces and ignore double quoted text?
Like in the below example.
hello "Luis Anderson" your age is 30 and u will get ...
0
votes
3answers
55 views
spliting string in java using regex
How can i split following string in two strings?
input:
00:02:05,130 --> 00:02:10,130
output:
00:02:05,130
00:02:10,130
i tried this piece of code:
String[] tokens = my.split(" --> ");
...
1
vote
4answers
100 views
Regex to find tokens - Java Scanner or another alternative
Hi I'm trying to write a class that transfers some text into well defined tokens.
The strings are somewhat similar to code like: (brown) "fox" 'c';. What I would like to get is (either a token from ...
1
vote
4answers
43 views
Regex using java string.replaceall
I am looking to replace a java string value as follows. below code is not working.
cleanInst.replaceAll("[<i>]", "");
cleanInst.replaceAll("[</i>]", "");
...
2
votes
6answers
78 views
Determine if a String contains an odd number of quotation marks
I'm trying to write a Regex expression that can determine if a string contains an odd number of " - quotation marks.
An answerer on this question has accomplished something very similar for ...
1
vote
4answers
80 views
How do I shorten this fragment of regex code?
I have the following function in Java, which takes in a String comment and returns comment but with all trailing # characters and any # characters that have a space after them remove, and any sequence ...