The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 8:18am
Pages: 1
Send Topic Print
Help Regular Expressions: /\<[a-z]\w*\>/ (Read 3106 times)
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

Help Regular Expressions: /\<[a-z]\w*\>/
Aug 31st, 2008, 1:19am
 
Could perl expert help understand this?
Back to top
 
 
View Profile   IP Logged
jbdavid
Community Fellow
*****
Offline



Posts: 378
Silicon Valley
Re: Help Regular Expressions: /\<[a-z]\w*\>/
Reply #1 - Aug 31st, 2008, 1:02pm
 
Actually Perl Beginner could understand this.. its a very simple regular expression for a match..

^ matches the beginning of string
oops thats /\  not ^
m/<stuff>/  define a match string as defined by <stuff>
in this case <stuff> is \<[a-z]\w*\>
(m is not strictly required.. but my nedit syntax highlighter always recognizes match expressions if you use m/ -- so thats now my habit.)

so \< escapes a normally special character "<" so that you are looking for something between <>  for instance the CONTENTS of an xml tag
[a-z] requires the first letter to be in this range of characters - (lower case) - so tags starting with spaces, or CAPS or numbers DON'T MATCH
\w - Allows any of the legal "word" characters, lowercase, uppercase, numbers  -- and maybe "_" ?
* allows repeats of \w
---
I'll recommend investing in the "programming perl" book by larry Wall et al.
Disclaimer.. this is all from Memory.. and MY copy of the book is on my desk at the office.. - there are 20 forums on Perl coding similar to DG for analog / RF design.. and ALL the documentation is on the web too. so If I got it wrong from memory sorry.. I'm not going to google this answer for you.. Smiley
jbd
Back to top
 
 

jbdavid
Mixed Signal Design Verification
View Profile WWW   IP Logged
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

Re: Help Regular Expressions: /\<[a-z]\w*\>/
Reply #2 - Sep 1st, 2008, 6:00am
 
So, it should match a character start with a-z without white space, right?
Back to top
 
 
View Profile   IP Logged
neoflash
Community Fellow
*****
Offline

Mixed-Signal
Designer

Posts: 397

Re: Help Regular Expressions: /\<[a-z]\w*\>/
Reply #3 - Sep 1st, 2008, 6:13am
 
neoflash wrote on Aug 31st, 2008, 1:19am:
Could perl expert help understand this?


It is weird that when I try to search /\w, it returned only "w" matched results. Not expected word character. why?
Back to top
 
 
View Profile   IP Logged
jbdavid
Community Fellow
*****
Offline



Posts: 378
Silicon Valley
Re: Help Regular Expressions: /\<[a-z]\w*\>/
Reply #4 - Sep 3rd, 2008, 8:29am
 
1. with just a couple characters of your code.. we won't be able to tell you.
2. few members of this forum pride themselves on their perl knowledge while thousands of members of the perl community gather on other forums..
I find perl a useful tool, but program with "the book" open..
and there are 30 pages there on regular expressions.. which I haven't memorized.. but have consulted many times over the last 5 years..
the book = "programming perl" by Wall & Christenson (I think I have the authors right)
Its a GREAT value to have on hand.
Back to top
 
 

jbdavid
Mixed Signal Design Verification
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.