Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2012, 06:59 AM
denise1985 denise1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 denise1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m
Reputation Power: 0
Regex Match string AND not match string

Someone help me please!

I need a regular expression that match one string, and not match a second string in one.

example

The searchstring may not match the word "s=001" AND must match the word "msisdn="

I'm stuk on de Regex: ^((?!s=001).)*$

this search-string should return true:
/fotos/site29/set3/518.html?msisdn=%2B31&hash=1FCFA5888E

en this one false:
/fotos/site29/set3/518.html?msisdn=%2B31&hash=1FCFA5888E&s=001

Who can help me??

Reply With Quote
  #2  
Old October 15th, 2012, 07:13 AM
Jacques3 Jacques3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 57 Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 10 h 6 m 14 sec
Reputation Power: 11
Hi,

regexes are the wrong approach for this. If I understand you correctly, you want to make sure that certain URL parameters are given and others not.

The server language you're using (whatever that is) is much better suited for this kind of task. The parameters are probably parsed automatically (in PHP, for example, they're in the $_GET array). So you can do some simple checks directly on the parameters and don't need to write your own home-made URL parser.

Reply With Quote
  #3  
Old October 15th, 2012, 08:05 AM
denise1985 denise1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 denise1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m
Reputation Power: 0
Quote:
Originally Posted by Jacques3
Hi,

regexes are the wrong approach for this. If I understand you correctly, you want to make sure that certain URL parameters are given and others not.

The server language you're using (whatever that is) is much better suited for this kind of task. The parameters are probably parsed automatically (in PHP, for example, they're in the $_GET array). So you can do some simple checks directly on the parameters and don't need to write your own home-made URL parser.


Thanks for the quick response, but the problem is i have to check it with Regex and it's not an option to script it.
If it really is impossible, i have to find an other solution..
But thanks anyway!

Reply With Quote
  #4  
Old October 15th, 2012, 08:29 AM
Jacques3 Jacques3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 57 Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level)Jacques3 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 10 h 6 m 14 sec
Reputation Power: 11
Quote:
Originally Posted by denise1985
Thanks for the quick response, but the problem is i have to check it with Regex and it's not an option to script it.


Says who? What exactly do you need this for?

Yes, it's possible with a regex, but that's just ugly and far from a clean solution. And I can hardly think of a context where you actually have to parse and filter URL parameters with a regex.

Anyway, my idea would be
Code:
/^[^\?]*\?(?:(?!s=001)[^&]+&)*?misisdn=[^&]+(?:&(?!s=001)[^&]+)*$/

Reply With Quote
  #5  
Old October 15th, 2012, 09:17 AM
denise1985 denise1985 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 3 denise1985 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m
Reputation Power: 0
Quote:
Originally Posted by Jacques3
Says who? What exactly do you need this for?

Yes, it's possible with a regex, but that's just ugly and far from a clean solution. And I can hardly think of a context where you actually have to parse and filter URL parameters with a regex.

Anyway, my idea would be
Code:
/^[^\?]*\?(?:(?!s=001)[^&]+&)*?misisdn=[^&]+(?:&(?!s=001)[^&]+)*$/


I think i can use this! thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Regex Match string AND not match string

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap