The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl Design Languages >> Verilog-AMS >> Help Regular Expressions: /\<[a-z]\w*\>/ https://designers-guide.org/forum/YaBB.pl?num=1220170795 Message started by neoflash on Aug 31st, 2008, 1:19am |
Title: Help Regular Expressions: /\<[a-z]\w*\>/ Post by neoflash on Aug 31st, 2008, 1:19am Could perl expert help understand this? |
Title: Re: Help Regular Expressions: /\<[a-z]\w*\>/ Post by jbdavid on 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.. :) jbd |
Title: Re: Help Regular Expressions: /\<[a-z]\w*\>/ Post by neoflash on Sep 1st, 2008, 6:00am So, it should match a character start with a-z without white space, right? |
Title: Re: Help Regular Expressions: /\<[a-z]\w*\>/ Post by neoflash on Sep 1st, 2008, 6:13am neoflash wrote on Aug 31st, 2008, 1:19am:
It is weird that when I try to search /\w, it returned only "w" matched results. Not expected word character. why? |
Title: Re: Help Regular Expressions: /\<[a-z]\w*\>/ Post by jbdavid on 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. |
The Designer's Guide Community Forum » Powered by YaBB 2.2.2! YaBB © 2000-2008. All Rights Reserved. |