I understand that the following would split the line in words space
separated: string[] words = Regex.Split(text, @"\W+"); Why do we need
@ before regular expression?
Thanks 5 2148
In C# the backslash (\) serves for escaping characters, and when you want to
include the literal backslash you have to escape it in one of two ways:
1) using the @ prefix which escapes all backslashes, or
2) by escaping the backslash using another one, e.g. "\\W+"
I personally prefer and recommend the @ prefix because I don't have to do it
for further slashes.
--
Stanimir Stoyanov http://stoyanoff.info
"puzzlecracker" <ir*********@gmail.comwrote in message
news:9d**********************************@o40g2000 prn.googlegroups.com...
>I understand that the following would split the line in words space
separated: string[] words = Regex.Split(text, @"\W+"); Why do we need
@ before regular expression?
Thanks
On Nov 3, 9:09*am, "Stanimir Stoyanov" <stoya...@REMOVETHIS.live.com>
wrote:
In C# the backslash (\) serves for escaping characters, and when you wantto
include the literal backslash you have to escape it in one of two ways:
1) using the @ prefix which escapes all backslashes, or
2) by escaping the backslash using another one, e.g. "\\W+"
I personally prefer and recommend the @ prefix because I don't have to doit
for further slashes.
--
Stanimir Stoyanovhttp://stoyanoff.info
"puzzlecracker" <ironsel2...@gmail.comwrote in message
news:9d**********************************@o40g2000 prn.googlegroups.com...
I understand that the following would split the line in words space
separated: string[] words = Regex.Split(text, @"\W+"); Why do we need
@ before regular expression?
Thanks
I see, I use @ to escape line-breaks, that seems another useful
application.
Thanks
One thing to note though, if you use the @ prefix line breaks will not work.
This is, essentially, because the line break is escaped and the string is
interpreted as 'slash, r, slash, n' and not 'carriage return, line break'.
--
Stanimir Stoyanov http://stoyanoff.info
"puzzlecracker" <ir*********@gmail.comwrote in message
news:8b**********************************@s9g2000p rg.googlegroups.com...
On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOVETHIS.live.com>
wrote:
In C# the backslash (\) serves for escaping characters, and when you want
to
include the literal backslash you have to escape it in one of two ways:
1) using the @ prefix which escapes all backslashes, or
2) by escaping the backslash using another one, e.g. "\\W+"
I personally prefer and recommend the @ prefix because I don't have to do
it
for further slashes.
--
Stanimir Stoyanovhttp://stoyanoff.info
"puzzlecracker" <ironsel2...@gmail.comwrote in message
news:9d**********************************@o40g2000 prn.googlegroups.com...
I understand that the following would split the line in words space
separated: string[] words = Regex.Split(text, @"\W+"); Why do we need
@ before regular expression?
Thanks
I see, I use @ to escape line-breaks, that seems another useful
application.
Thanks
Stanimir Stoyanov wrote:
One thing to note though, if you use the @ prefix line breaks will
not work. This is, essentially, because the line break is escaped and
the string is interpreted as 'slash, r, slash, n' and not 'carriage
return, line break'.
Line breaks work fine.
But they look like this:
string s = @"
";
not this:
string s = @"\r\n";
>
"puzzlecracker" <ir*********@gmail.comwrote in message
news:8b**********************************@s9g2000p rg.googlegroups.com...
On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOVETHIS.live.com>
wrote:
>In C# the backslash (\) serves for escaping characters, and when you want to include the literal backslash you have to escape it in one of two ways: 1) using the @ prefix which escapes all backslashes, or 2) by escaping the backslash using another one, e.g. "\\W+"
I personally prefer and recommend the @ prefix because I don't have to do it for further slashes. -- Stanimir Stoyanovhttp://stoyanoff.info
"puzzlecracker" <ironsel2...@gmail.comwrote in message
news:9d**********************************@o40g200 0prn.googlegroups.com...
>>I understand that the following would split the line in words space separated: string[] words = Regex.Split(text, @"\W+"); Why do we need @ before regular expression?
>>Thanks
I see, I use @ to escape line-breaks, that seems another useful
application.
Thanks
Thanks for pointing this out, Ben.
"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:et**************@TK2MSFTNGP04.phx.gbl...
Stanimir Stoyanov wrote:
>One thing to note though, if you use the @ prefix line breaks will not work. This is, essentially, because the line break is escaped and the string is interpreted as 'slash, r, slash, n' and not 'carriage return, line break'.
Line breaks work fine.
But they look like this:
string s = @"
";
not this:
string s = @"\r\n";
>> "puzzlecracker" <ir*********@gmail.comwrote in message news:8b**********************************@s9g2000 prg.googlegroups.com... On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOVETHIS.live.com> wrote:
>>In C# the backslash (\) serves for escaping characters, and when you want to include the literal backslash you have to escape it in one of two ways: 1) using the @ prefix which escapes all backslashes, or 2) by escaping the backslash using another one, e.g. "\\W+"
I personally prefer and recommend the @ prefix because I don't have to do it for further slashes. -- Stanimir Stoyanovhttp://stoyanoff.info
"puzzlecracker" <ironsel2...@gmail.comwrote in message
news:9d**********************************@o40g20 00prn.googlegroups.com...
I understand that the following would split the line in words space separated: string[] words = Regex.Split(text, @"\W+"); Why do we need @ before regular expression?
Thanks
I see, I use @ to escape line-breaks, that seems another useful application.
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin Lucas-Smith |
last post by:
Is there some way of using ereg to detect when certain filename extensions
are supplied and to return false if so, WITHOUT using the ! operator
before ereg () ?
I have an API that allows as an...
|
by: Lukas Holcik |
last post by:
Hi everyone!
How can I simply search text for regexps (lets say <a
href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a
dictionary { name : URL}? In a single pass if it could....
|
by: joh12005 |
last post by:
Hello,
here is a trouble that i had, i would like to resolve it with python,
even if i still have no clue on how to do it.
i had many small "text" files, so to speed up processes on them, i...
|
by: Illya Havsiyevych |
last post by:
Hello
Anybody knows regexp used in CodeModule Find Method
I'm trying to use regexp's to find all procedures in CodeModule
Maybe there is other way in Access
Thank You
Illya
|
by: Jon Maz |
last post by:
Hi All,
I want to strip the accents off characters in a string so that, for example,
the (Spanish) word "práctico" comes out as "practico" - but ignoring case,
so that "PRÁCTICO" comes out as...
| |
by: Edward |
last post by:
I need to validate a text box entry, but ONLY if it is 17 characters,
otherwise I have to ignore it. My regular expression for the
validation is:
^(({9})()()(\d{6}))$
Can I adapt this to...
|
by: HopfZ |
last post by:
I coudn't understand some behavior of RegExp.test function.
Example html code:
----------------
<html><head></head><body><script type="text/javascript">
var r = /^https?:\/\//g;...
|
by: eight02645999 |
last post by:
hi
suppose i have a string like
test1?test2t-test3*test4*test5$test6#test7*test8
how can i construct the regexp to get test3*test4*test5 and
test7*test8, ie, i want to match * and the words...
|
by: VUNETdotUS |
last post by:
Hi, I am working with this regexp to extract address: city, state, and
zip. This version kinda works but it extracts one element of an array
instead of three and keeps my "city" too long, including...
|
by: EME |
last post by:
typeof new RegExp
----------------------------------------------------
Why (new RegExp) type is function not object
very thanks for you consulation
|
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: 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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |