Hi all,
let say that my string is :
/// <author> aaa
/// <author> bbb
/// <author> ccc
1. how do i match all the authors except author aaa ?
2. how do i append the string "2006" to the authors names found in #1 ?
Thanks. 8 1667
yaron wrote: Hi all,
let say that my string is : /// <author> aaa /// <author> bbb /// <author> ccc
1. how do i match all the authors except author aaa ?
(?<line>///\s<author>\s(?!aaa)(?<author>.*))
2. how do i append the string "2006" to the authors names found in #1 ?
Use the Replace method on the above regex and replace with: ${line} 2006
... there are probably smarter expressions than this..!
hth,
Max
Markus Stoeger wrote: yaron wrote:
Hi all,
let say that my string is : /// <author> aaa /// <author> bbb /// <author> ccc
1. how do i match all the authors except author aaa ?
(?<line>///\s<author>\s(?!aaa)(?<author>.*))
2. how do i append the string "2006" to the authors names found in #1 ?
Use the Replace method on the above regex and replace with: ${line} 2006
.... a bit easier:
///\s<author>\s(?!aaa)(?<author>.*)
and replace with:
$& 2006
Max
yaron wrote: let say that my string is : /// <author> aaa /// <author> bbb /// <author> ccc
1. how do i match all the authors except author aaa ?
Regex regex = new Regex(@"(?:///\s<author>\s)([^aaa].+)",
(RegexOptions) 0);
2. how do i append the string "2006" to the authors names found in #1 ?
Use Replace with "$1 2006" as the replacement string.
--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Hi Markus,
thanks, it's work in the Expresso tool but not in the VS2003 IDE find
(Ctrl^F) using regular expression, do you know how to use it in the IDE or
maybe the VS2003 IDE doesn't support this regular expression ?
Thanks.
"Markus Stoeger" wrote: Markus Stoeger wrote: yaron wrote:
Hi all,
let say that my string is : /// <author> aaa /// <author> bbb /// <author> ccc
1. how do i match all the authors except author aaa ?
(?<line>///\s<author>\s(?!aaa)(?<author>.*))
2. how do i append the string "2006" to the authors names found in #1 ?
Use the Replace method on the above regex and replace with: ${line} 2006
.... a bit easier:
///\s<author>\s(?!aaa)(?<author>.*)
and replace with:
$& 2006
Max
Ken Arway wrote: yaron wrote:
let say that my string is : /// <author> aaa /// <author> bbb /// <author> ccc
1. how do i match all the authors except author aaa ?
Regex regex = new Regex(@"(?:///\s<author>\s)([^aaa].+)", (RegexOptions) 0);
The [^aaa] isn't right.. it means "match any <author> that isn't
followed by *one* 'a'" (instead of three a's). So for example abb will
not match either.
Max
yaron wrote: Hi Markus,
thanks, it's work in the Expresso tool but not in the VS2003 IDE find (Ctrl^F) using regular expression, do you know how to use it in the IDE or maybe the VS2003 IDE doesn't support this regular expression ?
I thought you wanted to do this with code (using the Regex class).. :)
What they have in the CTRL-F dialog doesn't look like the regular
expressions I'm used to.. but this should work:
search for:
{/// \<author\> ~(aaa).*}
replace with:
\1 2006
hth,
Max
Markus Stoeger wrote: Regex regex = new Regex(@"(?:///\s<author>\s)([^aaa].+)", (RegexOptions) 0);
The [^aaa] isn't right.. it means "match any <author> that isn't followed by *one* 'a'" (instead of three a's). So for example abb will not match either.
Yep...needed to use the negative look-ahead:
Regex regex = new Regex(@"(?:///\s<author>\s)((?!aaa).+)", (RegexOptions) 0);
--
Take care,
Ken
(to reply directly, remove the cool car. <sigh>)
Thanks to all for your help.
"Markus Stoeger" wrote: yaron wrote: Hi Markus,
thanks, it's work in the Expresso tool but not in the VS2003 IDE find (Ctrl^F) using regular expression, do you know how to use it in the IDE or maybe the VS2003 IDE doesn't support this regular expression ?
I thought you wanted to do this with code (using the Regex class).. :)
What they have in the CTRL-F dialog doesn't look like the regular expressions I'm used to.. but this should work:
search for:
{/// \<author\> ~(aaa).*}
replace with:
\1 2006
hth, Max This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Toby |
last post by:
Could some tell how I could create a search replace Regular Express in .net
where is would
match
MY_STRING_TO_BE_CONVERTED
and replace with
MyStringToBeConverted
|
by: Patient Guy |
last post by:
Coding patterns for regular expressions is completely unintuitive, as far
as I can see. I have been trying to write script that produces an array
of attribute components within an HTML element.
...
|
by: norton |
last post by:
Hello,
Does any one know how to extact the following text into 4 different
groups(namely Date, Artist, Album and Quality)?
- Artist - Album
Artist - Album
- Artist - Album
- Artist -...
|
by: Együd Csaba |
last post by:
Hi All,
I'd like to "compress" the following two filter expressions into one -
assuming that it makes sense regarding query execution performance.
.... where (adate LIKE "2004.01.10 __:30" or...
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Ludwig |
last post by:
Hi,
i'm using the regular expression \b\w to find the beginning of a word,
in my C# application. If the word is 'public', for example, it works.
However, if the word is '<public', it does not...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: =?Utf-8?B?SlA=?= |
last post by:
I am a newbie to regular expressions and want to extract a number from the
end of a string. The string would have these formats:
image/4567
image/45678
image/456789
I would also want to...
|
by: FAQEditor |
last post by:
Anybody have any URL's to tutorials and/or references for Regular
Expressions?
The four I have so far are:
http://docs.sun.com/source/816-6408-10/regexp.htm...
|
by: Rene |
last post by:
I'm trying to basically remove chunks of html from a page but I must
not be doing my regular expression correctly.
What i'm trying with no avail.
$site = preg_replace("/<!DOCTYPE(.|\s)*<div...
|
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$) {
}
...
|
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...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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...
| |