Re: Regulat expression question



(?<=User\s+ID\s*=\s*)[^;]+

It's not necessary to test for any previous text. Also, this version
accounts for possible line breaks in the Connection String.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Jesse Houwing" <jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:%23RZlp3PjHHA.4624@xxxxxxxxxxxxxxxxxxxxxxx
* Göran Andersson wrote, On 2-5-2007 15:20:
mamin@xxxxx wrote:
Hi, I have the following string:

"Data source=(local);Initial catalog=GeomelioDaneEwidencyjne;User
ID=aaa;Password=bbbbb;"

I need to get values of User ID from it. (aaa),

how can I do it using regular expressions?


Adding the special case that the user id may be the last parameter, not
followed by a semicolon (which is not appearent from your example), this
pattern would work:

"(?:^|;)User ID=([^;]+)(?:;|$)"


(?<=(?:;|^)\s*User ID\s*=\s*)[^;]+

Should result in only the text following User ID as match. Which is
probably easier to use.

Jesse


.



Relevant Pages

  • Re: Event Handler help
    ... Kevin Spencer ... FTP Client Classes, Enhanced Data Controls, much more. ... DSI PrintManager, Miradyne Component Libraries:http://www.miradyne.net ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Button with arrowdown (acting as a combobox)
    ... In that case, create a button that has an arrow on it, and put it next to ... Kevin Spencer ... FTP Client Classes, Enhanced Data Controls, much more. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: 404 not found
    ... Can you quote the IIS log file? ... Kevin Spencer ... FTP Client Classes, Enhanced Data Controls, much more. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: image to address bar of IE
    ... Kevin Spencer ... FTP Client Classes, Enhanced Data Controls, much more. ... i written code within in head tag ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: error while using SmtpMail to send a simple html formatted mes
    ... FTP Client Classes, Enhanced Data Controls, much more. ... DSI PrintManager, Miradyne Component Libraries: ... "Kevin Spencer" wrote: ... But my need is to send a HTML formatted message. ...
    (microsoft.public.dotnet.framework)