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 August 20th, 2008, 08:03 AM
Arem's Avatar
Arem Arem is offline
Classical Computing
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 893 Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 32 m 29 sec
Reputation Power: 101
Regex symbol for a tab

I love the idea of this new forum.

Today I tried using a PHP regex to validate basic HTML code in a textarea. I tested the regex by posting some valid HTML code but the regex kept rejecting it. I finally realized that there were some tabs in the HTML that were causing the problem. I'd like to keep the option of having tabs in the code.

So my question is, what's the best way to allow for a tab in a regex? I tried just typing a tab in the regex, and it worked, but it seems a poor way to go about it. I tried entering this tab symbol--& # 0 9 ; (without spaces, of course)--but that didn't work. Is there a better one, or is this just not Kosher anyway?

I'd love to know if anyone has any suggestions. I'm a newbie at this, and still using eregi, since I'm not confident about preg_match yet. If anyone knows of a really clear outline of the preg_match syntax I'd be grateful.
__________________
Simple is beautiful.

Last edited by Arem : August 20th, 2008 at 08:05 AM.

Reply With Quote
  #2  
Old August 20th, 2008, 08:28 AM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,476 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 4 h 42 m 37 sec
Reputation Power: 2194
\t is usually the way to do it.

Reply With Quote
  #3  
Old August 20th, 2008, 08:38 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Sep 2001
Location: Shanghai, An tSín
Posts: 6,894 ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level)ishnid User rank is General 44th Grade (Above 100000 Reputation Level) 
Time spent in forums: 4 Months 2 Weeks 1 Day 22 h 14 m 53 sec
Reputation Power: 3885
Yes, \t is for a tab. The whitespace character class (\s) will cover tabs along with other forms of whitespace (spaces, newlines, etc).

For the record I'm not a PHPer. In a Perl forum I would normally suggest that you not try to write regexps for parsing HTML (unless you're just practicing of course) but use a proper HTML parsing library. I guarantee it'll be easier and more reliable for you.

Regexps are not always the answer.

Reply With Quote
  #4  
Old August 20th, 2008, 06:57 PM
Arem's Avatar
Arem Arem is offline
Classical Computing
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 893 Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 32 m 29 sec
Reputation Power: 101
Thank you both very much for your replies. Much appreciated.

Now I am off to find out what an "HTML parsing library" is. Sounds interesting. (As I say, I'm very new at this...)

Best wishes.

Reply With Quote
  #5  
Old August 20th, 2008, 07:15 PM
ptr2void ptr2void is offline
I haz teh codez!
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Dec 2003
Posts: 2,476 ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level)ptr2void User rank is General 18th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 4 h 42 m 37 sec
Reputation Power: 2194
Here's one. I can't vouch for it as I've not had any needs to do HTML parsing, but it at least looks like it has some docs.

Reply With Quote
  #6  
Old August 20th, 2008, 10:30 PM
Arem's Avatar
Arem Arem is offline
Classical Computing
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Melbourne, Australia
Posts: 893 Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level)Arem User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 17 h 32 m 29 sec
Reputation Power: 101
@ptr2void: Gracias! I'll try it out.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Regex symbol for a tab

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