473,480 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Regex - POSIX v. .NET

I'm trying to put tegether a parser for parsing an HTTP user-agent string.

According to this doument:
http://www.texsoft.it/index.php?c=so...useragent&l=it

the following POSIX regex:
^([^/[:space:]]*)(/([^[:space:]]*))?([[:space:]]*\[[a-zA-Z][a-zA-Z]\])?[[:space:]]*(\\((([^()]|(\\([^()]*\\)))*)\\))?[[:space:]]*

when run on something like this:
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10) Gecko/20050716
Firefox/1.0.6

should give the following matches:
Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10)
Gecko/20050716
Firefox/1.0.6

Unfortunately the patten doesn't work in .NET. It gives something like
this:

<blank>
Mozilla
/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10) Gecko/20050716
Firefox/1.0.6
5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.7.10) Gecko/20050716
Firefox/1.0.6
<blank>
<blank>

I've tried in my own C# code as well as with Expresso. They give the same
matches as each other, but not what the doc claims it should get (and what I
need to get).

Now I know only enough about regex to know that it's a black art that I
really don't want to know about. Anyone see anything obviously wrong with
the pattern?

-Chris
Dec 7 '07 #1
0 1116

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

Similar topics

3
1491
by: Mark | last post by:
hello! I'm trying to use the POSIX regex syntax in PHP, and having a bit of trouble with word boundary separators. The basic syntax i have seen in the various tutorials i have read over the...
8
2960
by: Johnny | last post by:
I need to determine whether a text box contains a value that does not convert to a decimal. If the value does not convert to a decimal, I want to throw a MessageBox to have the user correct the...
7
5700
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
1
1127
by: David Garamond | last post by:
Is there anyone on this list who has preferred to use regexes from PL's (e.g. plperl, plruby) in CHECK constraints or other places instead of the flavor provided by Postgres? Do you find your...
3
3006
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular...
4
1996
by: Marcus | last post by:
Hello, I am trying to include the literal '\' (backslash) character in a regex. I am not sure if I need to escape it, however... From http://www.regular-expressions.info/charclass.html: "To...
10
3822
by: igor.kulkin | last post by:
I have a small utility program written in Python which works pretty slow so I've decided to implement it in C. I did some benchmarking of Python's code performance. One of the parts of the program...
1
1299
by: dbdariusz | last post by:
Hi input: <!-- comment -- <script><!-- comment --</scritp <!-- comment --> output: <script><!-- comment --></scritp>
3
1599
by: Medardo Rodriguez | last post by:
On Fri, Aug 22, 2008 at 11:24 AM, Dan <redalastor@gmail.comwrote: You can call *grep* posix utility. But if the regex's matches are possible only inner the context of a line of that file:...
0
6904
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
7034
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
7076
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...
1
6732
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...
0
5324
agi2029
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,...
1
4768
isladogs
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...
0
4472
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...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
bsmnconsultancy
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...

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.