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

Adding a literal to a regex match

Is there a way to add a literal character to a regex match? For example,
normally applying the regex ..$ to the string "123456" results in a match
"56". I want to be to add a literal character to the beginning of the
resultant match string. In other words, is there a regex that could be
applied to the string "123456" to a get a match string "056"?

Thanks.

Nov 16 '05 #1
1 1870
"Lee Kuhn" <le******@grsinc.com> wrote in
news:%2******************@tk2msftngp13.phx.gbl...
Is there a way to add a literal character to a regex match? ...


Yes:
Match m = Regex.Match(...);
string x = "0" + m.ToString();

I guess you somehow wanted to state this 'inside' the regex search pattern.
As the name says it's a search pattern, so, no, you cannot do this.

Niki
Nov 16 '05 #2

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

Similar topics

0
by: Lee Kuhn | last post by:
Is there a way to add a literal character to a regex match? For example, normally applying the regex ..$ to the string "123456" results in a match "56". I want to be to add a literal character to...
3
by: Jeff McPhail | last post by:
I am using Regex.Match in a large application and the memory is growing out of control. I have tried several ways to try and release the memory and none of them work. Here are some similar examples...
1
by: howard dierking | last post by:
Hi all, I'm having a problem with a reg ex. Essentiall, I'm trying to isolate variable declarations from old vbscript where there was no explicit declaration requirement. This should seem easy...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
5
by: Kofi | last post by:
Any takers? Got a string of DNA as an input sequence GGATGGATG, apply the simple regex "GGATG" as in Regex r = new Regex("GGATG", (RegexOptions.Compiled)); MatchCollection matches =...
3
by: aspineux | last post by:
My goal is to write a parser for these imaginary string from the SMTP protocol, regarding RFC 821 and 1869. I'm a little flexible with the BNF from these RFC :-) Any comment ? tests= def...
1
by: jonnyboy6969 | last post by:
Hi All Really hoping someone can help me out here with my deficient regex skills :) I have a function which takes a string of HTML and replaces a term (word or phrase) with a link. The pupose...
2
by: h03Ein | last post by:
Hi! during my search on tokens in ANSI C I have found following specification for string literals based on regular expression in site http://www.lysator.liu.se/c/ANSI-C-grammar-l.html :...
1
by: al.moorthi | last post by:
the below program is working in Suse and not working on Cent 5: can any body have the solution ? #include <regex.h> #include <stdlib.h> #include <stdio.h> int main(){ char cool =...
4
by: seberino | last post by:
I'm looking over the docs for the re module and can't find how to "NOT" an entire regex. For example..... How make regex that means "contains regex#1 but NOT regex#2" ? Chris
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: 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
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?
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
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
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.