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

Regex: How to find a "<" less than Symbol

Hi there,

since < has a meaning in c# for regular expressions and \< says it's
an unrecognized escape sequence, I'm pretty lost parsing html tags
without replacing them first with another character or string.
Does anyone have a hint for me on how to get c# Regex class to find
"<"?

Thanks in advance,

Prattel
Jun 27 '08 #1
3 14120
ch***********@gmail.com wrote:
Hi there,

since < has a meaning in c# for regular expressions and \< says it's
an unrecognized escape sequence, I'm pretty lost parsing html tags
without replacing them first with another character or string.
Does anyone have a hint for me on how to get c# Regex class to find
"<"?

Thanks in advance,

Prattel
"\\<"

or:

@"\<"

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #2
<ch***********@gmail.comwrote:
since < has a meaning in c# for regular expressions and \< says it's
an unrecognized escape sequence, I'm pretty lost parsing html tags
without replacing them first with another character or string.
Does anyone have a hint for me on how to get c# Regex class to find
"<"?
You need to differentiate between the escaping that C# is involved in,
and escaping that regular expressions need.

The two simplest ways of expressing the string consisting of a
backslash and an open angle bracket are:

"\\<"

This uses \\ to form a single backslash in the string, using normal C#
escaping. The single backslash is used to escape the angle bracket from
the point of view of the regex.
@"\<"

This uses a C# verbatim string literal to represent the same string -
again, so the single backslash is used to escape the angle bracket.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jun 27 '08 #3
Oh dear.. thank you, that did the trick :)
Jun 27 '08 #4

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

Similar topics

5
by: Eric A. Forgy | last post by:
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double array,double val,String...
2
by: J.D. Buehls | last post by:
I am displaying some values on a report. I am opening the .asp page with a Response.ContentType = "application/msword" and these particular values appear in a table. One column shows percentages...
7
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex'...
1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
16
by: rik | last post by:
I was flicking through a PHP book (one of the teach in 24 hour ones) and I came across something I had never seen before in PHP. It was a method of printing out without using the print method, it...
4
by: wangzhihuii | last post by:
Hi all, I'm really confused, can cout<<""; contribute anything to the routine ?!! my programm won't work properly without this trivial sentence. Sincerely vivian
9
by: Bill Yin | last post by:
what's mean?
2
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node...
11
by: Holger | last post by:
Hi I have not been able to figure out how to do compound statement from C - "<test>?<true-val>:<false-val>" But something similar must exist...?! I would like to do the equivalent if python...
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
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
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
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,...
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.