Is it possible to do multiple replaces in a string?
Example: I'm trying to replace all of the spaces with "%20" and "#" with
"%23", etc. I also need to replace the "?", "!", " ' ", etc.
I know I can do this with:
thisString.Replace(" ", "%20")
thisString.Replace("#", "%23")
But, I'm trying to find a way to do this one line of code.
Any Ideas?
TIA
JS 2 2781
Check Regex.Replace
HTH
Alex
"JS" <no*****@northere.com> wrote in message
news:re********************@comcast.com... Is it possible to do multiple replaces in a string?
Example: I'm trying to replace all of the spaces with "%20" and "#" with "%23", etc. I also need to replace the "?", "!", " ' ", etc.
I know I can do this with: thisString.Replace(" ", "%20") thisString.Replace("#", "%23")
But, I'm trying to find a way to do this one line of code.
Any Ideas?
TIA
JS
JS,
Have you tried: thisString.Replace(" ", "%20") thisString.Replace("#", "%23")
thisString = thisString.Replace(" ", "%20").Replace("#", "%23").
Example: I'm trying to replace all of the spaces with "%20" and "#" with "%23", etc. I also need to replace the "?", "!", " ' ", etc.
Although you may be approaching enough replacements that I would consider
using a StringBuilder instead. I would encapsulate the use of the
StringBuilder into a function, or possibly even a class.
Hope this helps
Jay
"JS" <no*****@northere.com> wrote in message
news:re********************@comcast.com... Is it possible to do multiple replaces in a string?
Example: I'm trying to replace all of the spaces with "%20" and "#" with "%23", etc. I also need to replace the "?", "!", " ' ", etc.
I know I can do this with: thisString.Replace(" ", "%20") thisString.Replace("#", "%23")
But, I'm trying to find a way to do this one line of code.
Any Ideas?
TIA
JS
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David |
last post by:
Hi,
I have a replace function <%= Replace(arData(0,i), "_", " ")%> that works
fine to replace the _ with a space, but I'd also like it to look for, and
replace one word with another in the same...
|
by: JeeWee |
last post by:
Hi all,
I'm looking for a way to "bind" multiple eventhandler function to the same
event. In other languages this can often be done by using the += operator,
unfortunately this doesn't seem to...
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if...
|
by: tshad |
last post by:
I have a textbox that I am storing as text (or as a varChar). The field has
multiple lines in it (not wrapped).
When I read it back into a multiline textbox, it works fine. But when I
read it...
|
by: Neo Geshel |
last post by:
Greetings
I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to...
|
by: Xah Lee |
last post by:
Interactive Find and Replace String Patterns on Multiple Files
Xah Lee, 2006-06
Suppose you need to do find and replace of a string pattern, for all
files in a directory. However, you do not...
|
by: vbisjustforme |
last post by:
sup guys, hit a mental snag an need some help.
i want to search a defined string (textbox),
and replace all characters in that string to Hex(KeyAscii) with "%" in front of the Hex(KeyAscii) right...
|
by: gblack301 |
last post by:
Hi,
I have a search form where the user can check a box or enter some data such as a name to quey the database. I was wondering what is the best way to enable the ability for a user data in more...
|
by: cmdolcet69 |
last post by:
Can anyone tell me if its possible to do multiple event args in vb.net?
|
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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...
| |