473,395 Members | 1,386 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,395 software developers and data experts.

Wildcard string search within a string

Hi all,
I want to remove this [878454]: With a string function? Can I use the Astric
as wild card? If not, how?

Dim txtstr as String = "Print Report for MRN [878454] from B Database"

txtstr = txtstr.Replace("[*]","")

please help
Nov 22 '05 #1
3 6950
Gerry Viator <vi*****@musc.edu> wrote:
I want to remove this [878454]: With a string function? Can I use the Astric
as wild card? If not, how?

Dim txtstr as String = "Print Report for MRN [878454] from B Database"

txtstr = txtstr.Replace("[*]","")


You could either use regular expressions, or find the first index of
the '[', then the first index of ']' after that, and remove that
section. Here's the regex:

using System;
using System.Text.RegularExpressions;

class Test
{
static void Main()
{
string test = "Print Report for MRN [878454] from B Database";

Regex regex = new Regex(@"\[.*\]");

Console.WriteLine (regex.Replace(test, ""));
}
}

Note that you end up with a double space in the middle that way.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
You won't be able to do this with the normal replace method, however
here is a link to a sample of how to do this using the regular
expression features of .Net.

http://www.regular-expressions.info/dotnet.html

The code is in C#, but you shouldn't have a real problem translating it
to VB.Net (I'm guessing that you use VB.Net from you original question).

Have A Better One!

John M Deal, MCP
Necessity Software

Gerry Viator wrote:
Hi all,
I want to remove this [878454]: With a string function? Can I use the Astric
as wild card? If not, how?

Dim txtstr as String = "Print Report for MRN [878454] from B Database"

txtstr = txtstr.Replace("[*]","")

please help

Nov 22 '05 #3
Thanks!!

that did it

Gerry
"Gerry Viator" <vi*****@musc.edu> wrote in message
news:ey**************@TK2MSFTNGP14.phx.gbl...
Hi all,
I want to remove this [878454]: With a string function? Can I use the
Astric as wild card? If not, how?

Dim txtstr as String = "Print Report for MRN [878454] from B Database"

txtstr = txtstr.Replace("[*]","")

please help

Nov 22 '05 #4

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

Similar topics

1
by: Generic Usenet Account | last post by:
Here's the requirement that I am trying to satisfy: Handle wildcards in STL such that the wildcard entry is encountered before non-wildcard entries while traversing containers like sets and...
2
by: Dave Smithz | last post by:
Hello there, Summary: How far can you go with SQL Select queries using like clauses with wildcard characters. Can you apply anything like regular expressions? Full details: On a Intranet...
1
by: deko | last post by:
I have a form where users can enter a string with asterisks to perform a wildcard search. Currently, the string entered by the user looks like this: *somestring* The purpose is to match any...
2
by: deko | last post by:
I'm trying to use a textbox to search and display records as each letter is typed in - similar to the behavior of a combo box. But for some reason I can't seem to get the wildcard search character...
2
by: RobC | last post by:
I have noticed that in the directoryInfo class a method named GetFiles(String) accepts a wildcard pattern as a parameter and uses this to match file names that exist in a directory. I want to use...
1
by: JemPower | last post by:
Hi all, Can someone tell me if it's possible to search through a dataview based on a part-filter. For example, if I use... Dim dvAvailable = New DataView(dsRecipients.Tables("Available"),...
2
by: JohnT | last post by:
Okay... I'm using VB.net (2003) and I am accessing an MS Access DB file. I have two DataAdapters that I use to search for specific info. The two of them are similar except one is a Date, the...
3
by: george.lengel | last post by:
Hello experts, I have been struggling for days to solve this problem and every suggestion I find via Google does not work for me. There is probably a solution out there that will do what I want,...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
2
by: Arch Stanton | last post by:
I have an aspx page with a text box. My user enters text to search for and presses a button; the text is passed via a QueryString to another aspx page and used in a SQL search. The wildcard...
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: 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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.