www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - help with RegExp not matching [D1]

reply jicman <cabrera_ _wrc.xerox.com> writes:
Greetings and salutations.

I am having trouble with this regular expression.  I tried a few things and
nothing.  Any help will be greatly appreciated.  Here is the program...

import std.stdio;
import std.regexp;


void main()
{
  char[] l, s, s0, str0;

  s = ";p=SomeCompany;l=USA0300MS01-091110184958Z-3076Delivery:";
  str0 = r"p=SomeCompany;l=[a-zA-Z0-9]+\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
  str0 = r"\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
  if (RegExp(str0).find(s) >= 0) // found
;p=XeroxCorp;l=USA0300MS01-091110184958Z-3076
  {
    writefln("Found it...");
  }
  else
    writefln("Not found...");
}

18:16:05.94>build -I..;c:\D\dmd\import regexp1.d

18:21:13.68>regexp1
Not found...

thanks for the help.

josť
Nov 22 2009
parent reply jicman <cabrera_ _wrc.xerox.com> writes:
jicman Wrote:

 Greetings and salutations.
 
 I am having trouble with this regular expression.  I tried a few things and
nothing.  Any help will be greatly appreciated.  Here is the program...
 
 import std.stdio;
 import std.regexp;
 
 
 void main()
 {
   char[] l, s, s0, str0;
 
   s = ";p=SomeCompany;l=USA0300MS01-091110184958Z-3076Delivery:";
   str0 = r"p=SomeCompany;l=[a-zA-Z0-9]+\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   str0 = r"\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   if (RegExp(str0).find(s) >= 0) // found
;p=XeroxCorp;l=USA0300MS01-091110184958Z-3076
   {
     writefln("Found it...");
   }
   else
     writefln("Not found...");
 }
 
 18:16:05.94>build -I..;c:\D\dmd\import regexp1.d
 
 18:21:13.68>regexp1
 Not found...
 
 thanks for the help.
 
 josť
Does anybody hve any ideas? thanks.
Nov 22 2009
parent reply jicman <cabrera_ _wrc.xerox.com> writes:
jicman Wrote:

 jicman Wrote:
 
 Greetings and salutations.
 
 I am having trouble with this regular expression.  I tried a few things and
nothing.  Any help will be greatly appreciated.  Here is the program...
 
 import std.stdio;
 import std.regexp;
 
 
 void main()
 {
   char[] l, s, s0, str0;
 
   s = ";p=SomeCompany;l=USA0300MS01-091110184958Z-3076Delivery:";
   str0 = r"p=SomeCompany;l=[a-zA-Z0-9]+\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   str0 = r"\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   if (RegExp(str0).find(s) >= 0) // found
;p=XeroxCorp;l=USA0300MS01-091110184958Z-3076
   {
     writefln("Found it...");
   }
   else
     writefln("Not found...");
 }
 
 18:16:05.94>build -I..;c:\D\dmd\import regexp1.d
 
 18:21:13.68>regexp1
 Not found...
 
 thanks for the help.
 
 josť
Does anybody hve any ideas? thanks.
Never mind... sorry about this. josť
Nov 22 2009
parent reply g <g g.g> writes:
jicman Wrote:

 jicman Wrote:
 
 jicman Wrote:
 
 Greetings and salutations.
 
 I am having trouble with this regular expression.  I tried a few things and
nothing.  Any help will be greatly appreciated.  Here is the program...
 
 import std.stdio;
 import std.regexp;
 
 
 void main()
 {
   char[] l, s, s0, str0;
 
   s = ";p=SomeCompany;l=USA0300MS01-091110184958Z-3076Delivery:";
   str0 = r"p=SomeCompany;l=[a-zA-Z0-9]+\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   str0 = r"\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   if (RegExp(str0).find(s) >= 0) // found
;p=XeroxCorp;l=USA0300MS01-091110184958Z-3076
   {
     writefln("Found it...");
   }
   else
     writefln("Not found...");
 }
 
 18:16:05.94>build -I..;c:\D\dmd\import regexp1.d
 
 18:21:13.68>regexp1
 Not found...
 
 thanks for the help.
 
 josť
Does anybody hve any ideas? thanks.
Never mind... sorry about this. josť
don't get disappointed. It happens in every community, that som answeres are not answred or answered in time. I may be because is a bit offtopic, also can be if "what is the problem with this [cryptic|strange1 whatever code] code", or simpley beacuse nones know what to say. In your case, i would say that be more explicit and don't be like "resolve my homework now". just general recomendations, and be patient. best regards. g
Nov 22 2009
parent jicman <cabrera_ _wrc.xerox.com> writes:
g Wrote:

 jicman Wrote:
 
 jicman Wrote:
 
 jicman Wrote:
 
 Greetings and salutations.
 
 I am having trouble with this regular expression.  I tried a few things and
nothing.  Any help will be greatly appreciated.  Here is the program...
 
 import std.stdio;
 import std.regexp;
 
 
 void main()
 {
   char[] l, s, s0, str0;
 
   s = ";p=SomeCompany;l=USA0300MS01-091110184958Z-3076Delivery:";
   str0 = r"p=SomeCompany;l=[a-zA-Z0-9]+\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   str0 = r"\-\d\d\d\d\d\d\d\d\d\d\d\dZ\-d\d\d\d";
   if (RegExp(str0).find(s) >= 0) // found
;p=XeroxCorp;l=USA0300MS01-091110184958Z-3076
   {
     writefln("Found it...");
   }
   else
     writefln("Not found...");
 }
 
 18:16:05.94>build -I..;c:\D\dmd\import regexp1.d
 
 18:21:13.68>regexp1
 Not found...
 
 thanks for the help.
 
 josť
Does anybody hve any ideas? thanks.
Never mind... sorry about this. josť
don't get disappointed. It happens in every community, that som answeres are not answred or answered in time. I may be because is a bit offtopic, also can be if "what is the problem with this [cryptic|strange1 whatever code] code", or simpley beacuse nones know what to say. In your case, i would say that be more explicit and don't be like "resolve my homework now". just general recomendations, and be patient. best regards. g
Thanks, g. What happened was that I figured it out. I was missing a \ in the first of the last 4 \d\d\d\d. So, I figured it out by making changes to the Regular Expression code. so, I felt ashamed and said never mind. :) I am patient. Do a search on jicman and you'll see plenty of posts. :-) Thanks, jic
Nov 22 2009