I want to replace + sign with 2 blackslash and 1 + sign (\\+)...
when I use the replaceAll()...
It throws a 500 status error like
"java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0"
wht s the solution or how can I replace ????
8 3028
I want to replace + sign with 2 blackslash and 1 + sign (\\+)...
when I use the replaceAll()...
It throws a 500 status error like
"java.util.regex.PatternSyntaxException: Dangling meta character '+' near index 0"
wht s the solution or how can I replace ????
Bit of a nasty one that - replaceAll("\\+", "\\\\\\\\+")
Bit of a nasty one that - replaceAll("\\+", "\\\\\\\\+")
How does it work can you explain?
Debasis Jana
How does it work can you explain?
Debasis Jana
Remember that + is a special character and \ is a special-special character.
To match one \ you need four \
I'm not a big fan of regex (They're why I run screaming from PERL, but then isn't that known as a "write once" language because you don't ever want to read your own code?).
Anyhowdy, if you are just replacing text, there is no need to use String's replaceAll method which drags regex patterns into the fray. Use String's replace method which simply replaces all occurrences of the first string with the second. - result = s.replace("+", "\\\\+");
(You still need to escape \ as you always do in any string, of course.) String.replace API
I'm not a big fan of regex (They're why I run screaming from PERL, but then isn't that known as a "write once" language because you don't ever want to read your own code?).
Anyhowdy, if you are just replacing text, there is no need to use String's replaceAll method which drags regex patterns into the fray. Use String's replace method which simply replaces all occurrences of the first string with the second. - result = s.replace("+", "\\\\+");
(You still need to escape \ as you always do in any string, of course.) String.replace API
Why do all mathematicians seem to have some sort of history with Perl ...
Why do all mathematicians seem to have some sort of history with Perl ...
Maybe it's being relegated to linux/UNIX machines where it's more likely you'll bump into it. That's what happened to me.
Maybe it's being relegated to linux/UNIX machines where it's more likely you'll bump into it. That's what happened to me.
Until now I managed to stay as far away as possible from Larry Wall's miscarriage.
I only trust that Perl as far as i can throw a rock at it.
kind regards,
Jos
Until now I managed to stay as far away as possible from Larry Wall's miscarriage.
I only trust that Perl as far as i can throw a rock at it.
kind regards,
Jos
I'm scared to look at the Perl forum to see what they're writing about us!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Luke Dalessandro |
last post by:
I have an application where there is a primary XML data file. I'll use
the following as an example:
<data>
<item id="a">
<name>A</name>
<price>$10</price>
</item>
<item id="b">...
|
by: vigi98 |
last post by:
Hello all,
Can someone confirme that this:
var strURLpiece = "UK & Ireland";
strURLpiece.replace("&", "%26");
replaces all occurrence of the character & by %26 in strURLpiece, ie
that...
|
by: asd987 |
last post by:
Hi,
Can anyone tell me if "replace" is supported by Access 97? I use the Dutch
version and get the errormessage "sub or function not supported". Or is the
Professional Edition needed?
Thanks.
|
by: ad |
last post by:
Hello, if I try this
((StringBuilder)sb).Replace("a", "aa");
I get OutOfMemoryException raised if sb contains at least one "a"...
It seems like StringBuilder 'seeker' doesn't move to the end...
|
by: Marty |
last post by:
Hi,
I would like to replace "\r\n" by "_" within a specific string.
I tried :
strMyString.Replace('\r', '_');
strMyString.Replace('\n', '_');
or...
|
by: Dean Slindee |
last post by:
Private NameLastFirst as object = "Public, John Q."
NameLastFirst = Replace(LastName, "'", "''")
If NameLastFirst contains "Public, John Q." before the above Replace, it
will contain "Public"...
|
by: Rave |
last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
|
by: John Nagle |
last post by:
I'm trying to clean up a bad ASCII string, one read from a
web page that is supposedly in the ASCII character set but has some
characters above 127. And I get this:
File...
|
by: jx2 |
last post by:
lets say i've got a str="john michael luise+marry"
i need to replace all ocurrance of name with name+surname
eg str2= "johnBrown michealBrown luiseBrown+marryBrown"
i gues i need something like...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |