CodingRegEX

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  steve  
 To:  ALL
37170.1 
Hello :C I am building a 400ish page catalogue for work with ZMags. They let you use Regular Expressions to build links. This excites me but I am not sure how they work. I need it to look for something like T112R045N but basically any Txxxxxxxx. So T followed by 8 letters or numbers. What is that? I wish to learn RegXP too.

xxx

0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  steve     
37170.2 In reply to 37170.1 
Well "T followed by 8 letters or numbers" is this:
code:
T[A-Z0-9]{8}


However, if you need to be sure that is isolated (i.e. not found in "ATTENTIVENESS"), then you want to use word boundary markers also:
code:
\bT[A-Z0-9]{8}\b

The \b matches the zero-width boundary between a "word character" (alpha,number,underscore) and a "non-word character" (everything else), in either direction.
If you have different/stricter rules, potentially a different expression is needed.

Also, that'll still match "TENTATIVE" though - so you'll need to clarify if you want, for example, at least 1 numeric digit, and if the position of that number might be important.

Similarly, is case important - should "t112r045n" match?
(If so, you can probably plonk (?i) at the start to set case-insensitive mode.)
0/0
 Reply   Quote More 

 From:  steve  
 To:  Peter (BOUGHTONP)     
37170.3 In reply to 37170.2 
I had figured out the T[A-Z0-9]{8} eventually but did not know about the isolated bits. Case should be fine!

ZMags link tool is doing RegEx bad and making errors even with their example one, so they are fixing it over night :C THANK YOU PETER :C

0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
37170.4 In reply to 37170.2 
I love RE's but they can sure fuck things up fast. I always do a compleat code bu before running a global search & replace on RE's.

----
What can't social media do?
  • Make coffee
  • Tie its shoes
  • Spell
0/0
 Reply   Quote More 

 From:  Peter (BOUGHTONP)  
 To:  CHYRON (DSMITHHFX)     
37170.5 In reply to 37170.4 
I'm not sure what a "code bu" is, but yes - any global search and replace is something to be careful about, and an imprecise regex is especially liable to unintentionally change things.

Still a great and underused/misused tool though.
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)  
 To:  Peter (BOUGHTONP)     
37170.6 In reply to 37170.5 
"bu" stands for beatific underling, of course...

----
What can't social media do?
  • Make coffee
  • Tie its shoes
  • Spell
0/0
 Reply   Quote More 

Reply to All    
 

1–6

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats