471,317 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

regex matching question

Hi,

I'm creating a little knowledge base webservice, which would help my users
when they
encounter errors.

In my knowledge base I would have entries like this:
problem: Can't access file[*] because it is being used by another process
fix: the file is currently in use so you can't use it now.

Lets say an IOException is thrown in the application with the message:
"Can't access file 'myfile.txt' because it is being used by another process"

The error would then be sent to the webservice, the webservice would
try to match the error message with the kbase and send back the response
if one is found.

My guess is this would be best done with regular expressions, right?

Please help,
thanks,
saso


Feb 20 '06 #1
3 1054
Saso Zagoranski <sa*************@guest.arnes.si> wrote:
I'm creating a little knowledge base webservice, which would help my users
when they
encounter errors.

In my knowledge base I would have entries like this:
problem: Can't access file[*] because it is being used by another process
fix: the file is currently in use so you can't use it now.

Lets say an IOException is thrown in the application with the message:
"Can't access file 'myfile.txt' because it is being used by another process"

The error would then be sent to the webservice, the webservice would
try to match the error message with the kbase and send back the response
if one is found.

My guess is this would be best done with regular expressions, right?


Yes, that sounds like a good fit for regular expressions. One thing to
bear in mind, however, is that regular expressions can be difficult to
write. Will you be the person writing all the knowledge base entries,
and are you comfortable with regular expressions (or happy to learn
about them)?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 20 '06 #2
Hi,

I will be the person who will write kbase entries and all of them
will be in the form:
text text[*] text text text
where[*] represents an any text. (I can use something else instead of[*]
if you
think it's better)

I don't have any knowledge of regex but I am willing to learn,
although I have to admit that I was hoping that there is an example out
there of how to do
what I'm looking for :)

thanks for your answer,
saso

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Saso Zagoranski <sa*************@guest.arnes.si> wrote:
I'm creating a little knowledge base webservice, which would help my
users
when they
encounter errors.

In my knowledge base I would have entries like this:
problem: Can't access file[*] because it is being used by another
process
fix: the file is currently in use so you can't use it now.

Lets say an IOException is thrown in the application with the message:
"Can't access file 'myfile.txt' because it is being used by another
process"

The error would then be sent to the webservice, the webservice would
try to match the error message with the kbase and send back the response
if one is found.

My guess is this would be best done with regular expressions, right?


Yes, that sounds like a good fit for regular expressions. One thing to
bear in mind, however, is that regular expressions can be difficult to
write. Will you be the person writing all the knowledge base entries,
and are you comfortable with regular expressions (or happy to learn
about them)?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Feb 20 '06 #3
Saso Zagoranski <sa*************@guest.arnes.si> wrote:
I will be the person who will write kbase entries and all of them
will be in the form:
text text[*] text text text
where[*] represents an any text. (I can use something else instead of[*]
if you think it's better)

I don't have any knowledge of regex but I am willing to learn,
although I have to admit that I was hoping that there is an example out
there of how to do what I'm looking for :)


Well, to do that, you could just convert the text into a regular
expression by escaping the bits at the start and end (so it doesn't
matter if you've got something which is special to regular expressions)
and replace the[*] with something like .* (which matches any
characters, basically).

You *could* do all that by splitting the string into a start bit and an
end bit, then using string.StartsWith and string.EndsWith. However,
things would get hairy if you then found yourself with two[*] tokens.

I suggest you read the MSDN pages on regular expressions - they're
worth delving into.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by aeuglein | last post: by
17 posts views Thread by clintonG | last post: by
5 posts views Thread by Kofi | last post: by
7 posts views Thread by CB | last post: by
6 posts views Thread by Martin Evans | last post: by
reply views Thread by Tidane | last post: by
4 posts views Thread by pedrito | last post: by
3 posts views Thread by Jeff | last post: by

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.