Need help in writing PCRE

V

vikrant

Hi everyone,

I know this not the right place to ask this question but i did not
found any group specific for discussion problem related to PCRE. But,
i believe members of this forum are having good in writing PCRE thats
why i am posting my question here.

I need ur help in writing the pcre for the following string

string :- ftp:\\abnssjs%20jfdhjdh.htc%00.mnd

Now, what i need to match is "ftp:" "anything in between except i.e
^(%00)" followed by "%00" then Dot

What i have tried so far is

1. /ftp:.*%00./i but .* match any thing including %00 (except
newline)
2. /ftp:(^\%00)*./i It's not working.
3. /ftp:^(%00)*./i It's not working.

The problem is ignore any character till particular string i.e "%00"
not come.

So,please help me out.

Regards,
Vikrant
 
B

Billy Patton

vikrant said:
Hi everyone,

I know this not the right place to ask this question but i did not
found any group specific for discussion problem related to PCRE. But,
i believe members of this forum are having good in writing PCRE thats
why i am posting my question here.

I need ur help in writing the pcre for the following string

string :- ftp:\\abnssjs%20jfdhjdh.htc%00.mnd

Now, what i need to match is "ftp:" "anything in between except i.e
^(%00)" followed by "%00" then Dot

What i have tried so far is

1. /ftp:.*%00./i but .* match any thing including %00 (except
newline)
2. /ftp:(^\%00)*./i It's not working.
3. /ftp:^(%00)*./i It's not working.

The problem is ignore any character till particular string i.e "%00"
not come.

So,please help me out.

Regards,
Vikrant


Try using Regex Coach
Best regular expression tool I have ever found
http://weitz.de/regex-coach/
 
D

David Sudlow

vikrant said:
Hi everyone,

I know this not the right place to ask this question but i did not
found any group specific for discussion problem related to PCRE. But,
i believe members of this forum are having good in writing PCRE thats
why i am posting my question here.

I need ur help in writing the pcre for the following string

string :- ftp:\\abnssjs%20jfdhjdh.htc%00.mnd

Now, what i need to match is "ftp:" "anything in between except i.e
^(%00)" followed by "%00" then Dot

What i have tried so far is

1. /ftp:.*%00./i but .* match any thing including %00 (except
newline)
2. /ftp:(^\%00)*./i It's not working.
3. /ftp:^(%00)*./i It's not working.

The problem is ignore any character till particular string i.e "%00"
not come.

So,please help me out.

Regards,
Vikrant

1. was pretty close but you forgot to escape the literal .
try
/ftp:.*%00\./i
 
V

vikrant

1. was pretty close but you forgot to escape the literal .
try
/ftp:.*%00\./i

Hi David,

Thanks for the reply.You are right i forgot this but my problem is
still persist because the problem occurring in .*

/ftp:.*%00\./i

here this pcre first matches "ftp:" then "any thing including %00
(except newline) because of .* " which i don't want.I want it to match
anything till it'll not find any "%00" then match DOT

Please correct me if i am wrong.

Regards,
Vikrant
 
D

David Sudlow

vikrant said:
Hi David,

Thanks for the reply.You are right i forgot this but my problem is
still persist because the problem occurring in .*

/ftp:.*%00\./i

here this pcre first matches "ftp:" then "any thing including %00
(except newline) because of .* " which i don't want.I want it to match
anything till it'll not find any "%00" then match DOT

Please correct me if i am wrong.

Regards,
Vikrant

That doesn't make a lot of sense to me.

Can you supply some examples of what you want to match and not match?

Does the expression given match the one example you gave in the language
you are using or not? (it would in perl).

Could you let us know exactly which regex engine you are using?
 
J

J. Gleixner

vikrant said:
Hi David,

Thanks for the reply.You are right i forgot this but my problem is
still persist because the problem occurring in .*

/ftp:.*%00\./i

here this pcre first matches "ftp:" then "any thing including %00
(except newline) because of .* " which i don't want.I want it to match
anything till it'll not find any "%00" then match DOT

Please correct me if i am wrong.

Regards,
Vikrant

/ftp:.*(?=%00\.)/
 
V

vikrant

That doesn't make a lot of sense to me.

Can you supply some examples of what you want to match and not match?

Does the expression given match the one example you gave in the language
you are using or not? (it would in perl).

Could you let us know exactly which regex engine you are using?

For Example:-

String :- ftp:\\abnssjs%20jfdhjdh.htc%00.mnd
Match :- ftp:\\abnssjs%20jfdhjdh.htc%00. (What i want)

String :- ftp:\\abnssjs%20jfdhjdh.ads%00.htc%00.exe
Match :- ftp:\\abnssjs%20jfdhjdh.ads%00. (What i want)

I am trying this on application supporting pcre library of http://www.pcre.org/

Regards,
Vikrant
 
D

David Sudlow

vikrant said:
For Example:-

String :- ftp:\\abnssjs%20jfdhjdh.htc%00.mnd
Match :- ftp:\\abnssjs%20jfdhjdh.htc%00. (What i want)

String :- ftp:\\abnssjs%20jfdhjdh.ads%00.htc%00.exe
Match :- ftp:\\abnssjs%20jfdhjdh.ads%00. (What i want)

I am trying this on application supporting pcre library of http://www.pcre.org/

Regards,
Vikrant
OK in perl you would specify lazy matching:
/ftp:.*?%00\./

and if you want to capture what matches (rather than just affirm a match):
/(ftp:.*?%00\.)/
 
V

vikrant

Try using Regex Coach
Best regular expression tool I have ever foundhttp://weitz.de/regex-coach/

Thanks for the suggestion.I am already using it.But,i preferred Regex
Buddy over Regex coach if it is free.
 
V

vikrant

OK in perl you would specify lazy matching:
/ftp:.*?%00\./

and if you want to capture what matches (rather than just affirm a match):
/(ftp:.*?%00\.)/

Thanks for the help.Now it's works well for second case also.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,204
Messages
2,571,065
Members
47,672
Latest member
svaraho

Latest Threads

Top