473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I can replace the text that is between "*" and "*" in a text file?

Hi! I use VB 2008 and I want to ask you how I can replace the text
that is between "*" and "*" in a text file?
If text file contains this:
*dog*
*cat*
*bird*
*lion*
*something*
.....end of file....
I want that the code will replace *dog* with *animal*,
*cat* with *animal* too
*lion* with *animal*
etc...
Thanks!
Jan 19 '08 #1
4 1287
alexvorn2 <al*******@gmail.comwrote in news:3169c06a-d42b-441d-9f8d-
05**********@s8g2000prg.googlegroups.com:
Hi! I use VB 2008 and I want to ask you how I can replace the text
that is between "*" and "*" in a text file?
If text file contains this:
*dog*
*cat*
*bird*
*lion*
*something*
....end of file....
I want that the code will replace *dog* with *animal*,
*cat* with *animal* too
*lion* with *animal*
Yes, you can use regular expressions to do this sort of ting.
I think \*\w\* should be able to find all matches.
--
sp**********@rogers.com (Do not e-mail)
Jan 19 '08 #2
On Jan 19, 11:14 pm, Spam Catcher <spamhoney...@rogers.comwrote:
alexvorn2 <alexvo...@gmail.comwrote in news:3169c06a-d42b-441d-9f8d-
056a9e32c...@s8g2000prg.googlegroups.com:
Hi! I use VB 2008 and I want to ask you how I can replace the text
that is between "*" and "*" in a text file?
If text file contains this:
*dog*
*cat*
*bird*
*lion*
*something*
....end of file....
I want that the code will replace *dog* with *animal*,
*cat* with *animal* too
*lion* with *animal*

Yes, you can use regular expressions to do this sort of ting.

I think \*\w\* should be able to find all matches.

--
spamhoney...@rogers.com (Do not e-mail)
Hi, but what I need to do to make this code to work?
For example this code: (it not works)

Dim TestString As String = "Sh*o*pping List"
' Returns "Shipping List".
Dim aString As String = Replace(TestString, "\*\w\* ", "i")
MsgBox(aString)
Jan 20 '08 #3
alexvorn2 <al*******@gmail.comwrote in news:bbc05d52-58b5-4617-afcb-
82**********@s19g2000prg.googlegroups.com:
Hi, but what I need to do to make this code to work?
For example this code: (it not works)

Dim TestString As String = "Sh*o*pping List"
' Returns "Shipping List".
Dim aString As String = Replace(TestString, "\*\w\* ", "i")
MsgBox(aString)
You have to use Regular Expressions... System.Text.RegularExpressions
Namespace.

--
sp**********@rogers.com (Do not e-mail)
Jan 20 '08 #4
On Jan 20, 8:16 pm, Spam Catcher <spamhoney...@rogers.comwrote:
alexvorn2 <alexvo...@gmail.comwrote in news:bbc05d52-58b5-4617-afcb-
822759e12...@s19g2000prg.googlegroups.com:
Hi, but what I need to do to make this code to work?
For example this code: (it not works)
Dim TestString As String = "Sh*o*pping List"
' Returns "Shipping List".
Dim aString As String = Replace(TestString, "\*\w\* ", "i")
MsgBox(aString)

You have to use Regular Expressions... System.Text.RegularExpressions
Namespace.

--
spamhoney...@rogers.com (Do not e-mail)
can you give me please an example?
Jan 20 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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">...
6
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...
3
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.
2
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...
6
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...
0
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...
5
by: xla76 | last post by:
Can anyone help me, I'm trying to replace any double quotes in a textbox with a different character. mystring = Replace(TextBox.Text , " , "*") I've tried chr(34) and """"" with no luck. ...
2
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...
5
by: Curious | last post by:
I have: if (temp.Contains("Account") == true) { temp.Replace("Account", "Client"); } The "Account" is not replaced by "Client" after this operation. I used
3
by: Curious | last post by:
I have another question about Regular Expression. If I use: if (temp.Contains("Ending") == true) { temp = System.Text.RegularExpressions.Regex.Replace(temp, "Ending", "Beginning"); } It...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.