I am trying to mix metacharacters and the literal versions
in an expression and no matter what I try it does not
work.
Here is the code
customer = Regex.Replace(customer,"[.]$","");
I want to remove all periods from the end of customer
names. However I really need to know how to
mix metacharacters and the literal versions ( mostly
periods ) in an expression. I have tried using \.
@ and other ways to escape out the period but with
zero success. 3 1769
customer = Regex.Replace(customer,"\\.$","");
or
customer = Regex.Replace(customer,@"\.$","");
Should both work fine. Your version ("[.]$") is considered "bad style", but
should nevertheless work. Post a short sample if it doesn't.
Niki
"Phil396" <an*******@discussions.microsoft.com> wrote in
news:2c*****************************@phx.gbl... I am trying to mix metacharacters and the literal versions in an expression and no matter what I try it does not work.
Here is the code
customer = Regex.Replace(customer,"[.]$","");
I want to remove all periods from the end of customer names. However I really need to know how to mix metacharacters and the literal versions ( mostly periods ) in an expression. I have tried using \. @ and other ways to escape out the period but with zero success.
Thanks for the information. I am doing regex
on web pages and spacing problems have been a nightmare.
Here is another case in point - there was an extra
space after the end of the period which made my
original expression incorrect. -----Original Message----- customer = Regex.Replace(customer,"\\.$",""); or customer = Regex.Replace(customer,@"\.$","");
Should both work fine. Your version ("[.]$") is
considered "bad style", butshould nevertheless work. Post a short sample if it
doesn't. Niki
"Phil396" <an*******@discussions.microsoft.com> wrote in news:2c*****************************@phx.gbl... I am trying to mix metacharacters and the literal
versions in an expression and no matter what I try it does not work.
Here is the code
customer = Regex.Replace(customer,"[.]$","");
I want to remove all periods from the end of customer names. However I really need to know how to mix metacharacters and the literal versions ( mostly periods ) in an expression. I have tried using \. @ and other ways to escape out the period but with zero success.
.
I expected something like that. You should maybe use some Regex tool like
"expresso" or "regulator" - those make it really easy to test regex's, and
they can create correct copy&paste C#-code.
And, thinking about it: maybe your regex should be tolerant enough to allow
spaces after customer names...
Niki
"Phil396" <an*******@discussions.microsoft.com> wrote in
news:2b*****************************@phx.gbl... Thanks for the information. I am doing regex on web pages and spacing problems have been a nightmare. Here is another case in point - there was an extra space after the end of the period which made my original expression incorrect.
-----Original Message----- customer = Regex.Replace(customer,"\\.$",""); or customer = Regex.Replace(customer,@"\.$","");
Should both work fine. Your version ("[.]$") is considered "bad style", butshould nevertheless work. Post a short sample if it doesn't. Niki
"Phil396" <an*******@discussions.microsoft.com> wrote in news:2c*****************************@phx.gbl... I am trying to mix metacharacters and the literal versions in an expression and no matter what I try it does not work.
Here is the code
customer = Regex.Replace(customer,"[.]$","");
I want to remove all periods from the end of customer names. However I really need to know how to mix metacharacters and the literal versions ( mostly periods ) in an expression. I have tried using \. @ and other ways to escape out the period but with zero success.
.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fernando Rodriguez |
last post by:
Hi,
I have a filewhose contents looks like this:
Compression=bzip/9
OutputBaseFilename=$<OutputFileName>
OutputDir=$<OutputDir>
LicenseFile=Z:\apps\easyjob\main\I18N\US\res\license.txt
...
|
by: bdwise |
last post by:
I have this in my body tag:
something();something();
document.thisForm.textBox1.focus();something();
And I want to find a part between the semicolons that ends in focus()
and remove the...
|
by: Tassos |
last post by:
I have a file with 2 fields (";" is the seperator): 1 string (field1) & 1 regex (field2)
test1;(+)
test2;(\w\d +)
test3;()
I want while reading the file to have an array being filled with...
|
by: Lord Khaos |
last post by:
If I am trying to find an expression, foo, I can do something like
this:
rExp = /foo/gi;
if(results.search(rExp) > -1){
and all work fine.
however, if I want my search term to be a...
|
by: Andrew Baker |
last post by:
I am trying to write a function which provides my users with a file
filter. The filter used to work just using the VB "Like" comparision,
but I can't find the equivilant in C#. I looked at...
|
by: Craig Kenisston |
last post by:
Hi,
I need to write a function that should behave like the SQL's "like" operator
on a list of words.
I was wondering if I can use Regex directly to do this job. But I've been
reading about...
|
by: bill tie |
last post by:
I'd appreciate it if you could advise.
1. How do I replace "\" (backslash) with anything?
2. Suppose I want to replace
(a) every occurrence of characters "a", "b", "c", "d" with "x",
(b)...
|
by: sd |
last post by:
Are any of the special range metacharacters allowed in
RegEx operations(System.Text.RegularExpressions) . If so
how could you please specify an example.
Thx!
sd
Only the digits 0 to 9
Any...
|
by: Kay Schluehr |
last post by:
I have a list of strings ls = and want to create a
regular expression sx from it, such that sx.match(s) yields a SRE_Match
object when s starts with an s_i for one i in . There might
be...
|
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: 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...
|
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:
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...
|
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: 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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |