I understand that the following would split the line in words space
separated: string[] words = Regex.Split(tex t, @"\W+"); Why do we need
@ before regular expression?
Thanks 5 2149
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
"puzzlecrac ker" <ir*********@gm ail.comwrote in message
news:9d******** *************** ***********@o40 g2000prn.google groups.com...
>I understand that the following would split the line in words space
separated: string[] words = Regex.Split(tex t, @"\W+"); Why do we need
@ before regular expression?
Thanks
On Nov 3, 9:09*am, "Stanimir Stoyanov" <stoya...@REMOV ETHIS.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
"puzzlecrac ker" <ironsel2...@gm ail.comwrote in message
news:9d******** *************** ***********@o40 g2000prn.google groups.com...
I understand that the following would split the line in words space
separated: string[] words = Regex.Split(tex t, @"\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
"puzzlecrac ker" <ir*********@gm ail.comwrote in message
news:8b******** *************** ***********@s9g 2000prg.googleg roups.com...
On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOV ETHIS.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
"puzzlecrac ker" <ironsel2...@gm ail.comwrote in message
news:9d******** *************** ***********@o40 g2000prn.google groups.com...
I understand that the following would split the line in words space
separated: string[] words = Regex.Split(tex t, @"\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";
>
"puzzlecrac ker" <ir*********@gm ail.comwrote in message
news:8b******** *************** ***********@s9g 2000prg.googleg roups.com...
On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOV ETHIS.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...@gm ail.comwrote in message
news:9d******* *************** ************@o4 0g2000prn.googl egroups.com...
>>I understand that the following would split the line in words space separated: string[] words = Regex.Split(tex t, @"\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.nos pamwrote in message
news:et******** ******@TK2MSFTN GP04.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*********@gm ail.comwrote in message news:8b******* *************** ************@s9 g2000prg.google groups.com... On Nov 3, 9:09 am, "Stanimir Stoyanov" <stoya...@REMOV ETHIS.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
"puzzlecracke r" <ironsel2...@gm ail.comwrote in message
news:9d****** *************** *************@o 40g2000prn.goog legroups.com...
I understand that the following would split the line in words space separated: string[] words = Regex.Split(tex t, @"\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 input a regular expression, enabling the
administrator to ensure a file upload matches a certain pattern. For
instance, supplying the string
...
|
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.
Or how can I replace the html &entities; in a string
"blablabla&blablabal&balbalbal" with the chars they mean using
re.sub? I found out they are...
|
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 used
to copy them inside a huge one adding some king of xml separator :
<file name="...">
|
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 "PRACTICO".
What's the best way to do this?
TIA,
| |
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 "fire" only if the string in question is 17 chars
in length? Or do I have to do this server-side?
Thanks
|
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;
document.write( );
</script></body></html>
---------------------
|
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 before and after?
thanks
|
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 all text
before it.
.....................
var regex = /\s*(.*)\s*,\s*({2})\s+(\d{5}(\-\d{4})?)\s*/g;
function doit(){
var arr =...
|
by: EME |
last post by:
typeof new RegExp
----------------------------------------------------
Why (new RegExp) type is function not object
very thanks for you consulation
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |