Inparablog

A comparative genomics and bioinformatics blog

  • Home
  • About
  • Perl
    • Arrays
    • RegExp
  • Links
  • Photos
  • Contact
RSS

RegExp

Special characters: . * ? + [ ] ( ) { } ^ $ | \

Grouping without backreferencing
/(?:Not Backreferenced)SomeTextToMatch(What I want to get backreferenced)/

Look ahead
/Look(?= ahead)/ Matches only ‘Look’ when it is followed by ‘ ahead’.
/Look(?! ahead)/ Matches only ‘Look’ when it is not followed by ‘ ahead’.

Look back
/(?< =Look )back)/ Matches only ‘back’ when it is preceded by ‘Look ‘.
/(?< !Look )back)/ Matches only ‘back’ when it is not preceded by ‘Look ‘.

RegExp special variables
$(num) Backreferences
$& Contains last successful match
$' Contains the substring following the last successful match
$` Contains the substring preceding the last successful match
@+ & @- I knew they were good for something! :)

Tricks
Getting all backreferences even though I do not know how many there will be.

my @array;
while ($string =~ /(SomethingToMatch):/g) {
      push @array, $1;
}

$1 can be substituted by $&

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*


question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Search

  • The author

    Gravatar My name is John van Dam and I am a Post-Doc at St. Radboud University Medical Center (NL). My research involves bioinformatics and comparative genomics on cilia and signal transduction pathways.
  • About me

    • LinkedIn Profile
    • Mendeley Profile
    • Research Blogging Profile
  • Bioinformatics Blogs

    • Bioinformatics
    • Bioinformatics Zen
    • Fisheye Perspective
    • nodalpoint
    • Omics! Omics!
    • Public Rambling
    • The Tree of Life
    • What You’re Doing Is Rather Desperate
    • YOKOFAKUN
  • Perl

    • Beginning Perl
    • Bio::Perl
    • PerlMonks
  • Tags

    Backreferences BBC Conference Cordyceps E-values Fungus Hardware Homology Insects Lightning Mac OS Meiosis Office paradox permalinks PhD Phylogenetic tree phylogeny Python Quadrupel radio Regexp Regular Expressions research Review software Thunder Trappist tree Upgrade Weather Westvleteren Westvleteren 12 Wordpress Youtube
  • Copyright notice

    Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    Creative Commons Licentie
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
© Inparablog. Proudly Powered by WordPress | Nest Theme by YChong