Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

A regular expression tutorial


  • Please log in to reply
23 replies to this topic
PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
OK, after some days of "rest" (doing something else), I finally acheived my regular expression tutorial!

You can find it on my site.

As I explain at the start, I tried to make a tutorial with concrete, real examples, yet avoiding forward references ("This expression uses some features we will see later"...), and trying to add some levity to this otherwise rather arid subject...

If you are curious and adventurous enough to read it, don't hesitate to give me feedback.
Feedback on the form (syntax, phrasing, sentences sounding too "Frenchy", etc.) should be private (PhiLho(a)GMX.net) to avoid adding noise to this topic.
Feedback on the content (is it clear enough, should I insist on some point, etc.) is welcome here.

Note that the page is printer friendly: I use a specific stylesheet for the printer (if your browser is smart enough) and you should be able to print in two columns, for example (if your driver is smart enough...).
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

BoBo
  • Guests
  • Last active:
  • Joined: --
Amazing! Thx for sharing it !! :D

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Thank you. FYI, I just added an example of alternatives, a big expression matching any valid date, including for leap years... An excellent example!
This page is likely to evolve, as ideas (and suggestions) come.
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i just finished reading some parts of it and it looks awesome! seems to be really helpful!

by the way you wrote all that yourself?... is it just me who hates documenting?!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

by the way you wrote all that yourself?... is it just me who hates documenting?!

PhiLho is crazy. :) Well done and thanks, PhiLho.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
I enjoy writing and explaining stuff... Why do you think I am near 2500 messages here?... ;-)
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
As you can see from my number of posts, this is not an unequivocal rule. :)
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
One word: G R E A T

Ciao
Micha

not-logged-in-daonlyfreez
  • Guests
  • Last active:
  • Joined: --
Wow!

I definately need to take the time for this one!

8)

Paulo not-logged
  • Guests
  • Last active:
  • Joined: --
Thanks PhiLho this one will help me a lot!

philou
  • Members
  • 68 posts
  • Last active: Jan 04 2011 01:12 PM
  • Joined: 26 Jul 2006
very cool, it's bookmarked and I'll maybe translate it to german if needed :)

JSLover
  • Members
  • 920 posts
  • Last active: Nov 02 2012 09:54 PM
  • Joined: 20 Dec 2004
Sorry, didn't read it...(I know regex's)...I might read it later, but I have some complaints...(would you expect any less from me?)...(by the time I finished posting, I have read it now...lol)...

/* Style common to all (most) other block tags */
p, td, blockquote, ul, ol
{
/*  padding: 0;*/
  font-style: normal;
  font-weight: normal;
  font-size: 1em;
  [color=blue]font-family: Verdana, Arial, Helvetica, sans-serif;[/color]
  color: #228;
}

/* Style common to all (most) other block tags */
p, td, blockquote, ul, ol
{
/*  padding: 0;*/
  font-size: 10pt;
  [color=red]font-family: Georgia, "Times New Roman", Times, serif;[/color]
  color: #000;
}
...why on God's earth would you focker with a nice font like Arial & make it Times New Roman for printing??? I hate Times New Roman...I would like to be able to try printing without that style being used, but the way you specified the stylesheets makes it automatic...can I suggest a Print button to switch styles to the print stylesheet...so people can see how bad it would print without it? The automaticness of doing it the way you did is nice, but when the "normal" way has a better font than the "print" way...you're stuck...unless I dig deep & make my own copy & delete the offending style reference...I prefer when I select Print (or Print Preview) in my browser to attempt to print what I see...not completely rewrite the page...(like Google Maps does)...only after failing that to click on a "Printer friendly" page (or stylesheet switcher...you don't need a complete separate copy...just a way to override the automatic print stylesheet)...

BTW...s/interrogation point/question mark/g...it's not interrogating anything & it's not a point...more...
[*:kqubf1kc]s/does the user has typed/did the user type/g
[*:kqubf1kc]s/instant a software/install software/g
[*:kqubf1kc]s/install a software to test off line/install software to test offline/g
[*:kqubf1kc]s/a very impressive software/a very impressive program/g...or just...very impressive software...a & software just don't sound right...
[*:kqubf1kc]s/underscode/underscore/g
[*:kqubf1kc]s/circumflex accent/carat/g...that may be the technical term, but we call it carat...
[*:kqubf1kc]s/an hex(adecimal)?/a hex\1/g
[*:kqubf1kc]s/Thues/Tues/g
[*:kqubf1kc]s/than an/that an/g...you also need to add the acronym resolver to PCRE (I know what it is, but do you...?)...ok, I see, you didn't add it to all occurrences...perhaps you should replace all acronyms dynamically with the html for the acronym tag thing...regex anyone?...(I already half wrote one to use bbcode IN html)...
Useful forum links: New content since: Last visitPast weekPast 2 weeks (links will show YOUR posts, not mine)

OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...

Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".

I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)
How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
In addition please change the background or the font colour. They both blend in with each other which makes it hard to read.

div #Container 1 set to an absolute width of 640px. On high resolutions this looks like a narrow block of compressed text. By making the width a percentage the text will be easy to read on all displays:

[quote name="http://phi.lho.free.fr/PhiLho_Layout.css"]#Container
{
width: 80%;
text-align: left;

padding-left: 10px;
padding-right: 10px;
border-left: 3px solid #008;
border-right: 3px solid #008;
}[/quote]

[quote name="http://phi.lho.free.fr/PhiLho_Look.css"]body
{
text-align: center;
margin: 0;
padding: 0;
font-size: 76%;
background: #EEF url(images/backgrounds/BodyBack.png) fixed 0 0;
}[/quote]

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


philou
  • Members
  • 68 posts
  • Last active: Jan 04 2011 01:12 PM
  • Joined: 26 Jul 2006

...why on God's earth would you focker with a nice font like Arial & make it Times New Roman for printing??? I hate Times New Roman..


To name Arial a "nice font" is almost as offending as using Times New Roman in print ;)
But basically, you're right.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

I hate Times New Roman..

Am I the only one who likes serif fonts :lol:

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit