EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff
Hacker's Home Page

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Articles



Return to Category Selection

Regex with PHP - Submitted By: NotMyOwn 2009-01-18 23:53:18
Regular Expressions (regex) with PHP for the beginner - NotMyOwn

------------------------------------

| The Basics |

Regular Expressions in PHP are generaly in corperated in PHP with preg_match(), I will give a few examples later.

A regex that will check to see if a string is a-z and A-Z looks like this
Code: [Select]

/^.[a-zA-Z].$/


A if...else in regex that checks to see if the number 1 or 2 was input looks like this
Code: [Select]

/^.[1|2].$/


Now, to check if it is in email syntax
Code: [Select]

/^.[a-zA-Z0-9_-.]+[@]+[a-zA-Z0-9_-]+[.]+([a-zA-Z.]{2,5}).$/


Now finally, to use PHP to check if a password is between 5 and 10 characters long
Code: [Select]

<?php
$password 
'ThisIsMyPass';

if (
preg_match('[/^.{5,10}$/]'$password))
{
  echo 
'Your password is between 5 and 10 characters!';
}
else
{
  echo 
'Your password is not between 5 and 10 characters!';
}
?>



This is EXTREAMLY basic, the resource I give below is much more in depth on Regular Expressions. This is just ment to be an example!
This is not in any way or form ment to give you an advanced knowledge of regex and how/why it works. This is simply BASIC syntax!
------------------------------------
Resources: http://www.webcheatsheet.com/php/regular_expressions.php
Helpful Programs: Regexbuddy (http://www.regexbuddy.com/)

Return to Category Selection
Comment By: ishkur88 2009-01-24 18:43:06
Email regular expressions are some of the trickiest you can make. The regular expressions website defines one possible way of searching for them: http://www.regular-expressions.info/regexbuddy/email.html

I've seen dozens of others as well.

Comment By: 0rijin4l 2009-01-26 18:42:11
nearly all of those regex's are wrong or inefficient. Plus why would you use regex for that PHP example. Just why.

Comment By: RedEvolution 2009-02-20 00:10:12
Quick question:
'[/^.{5,10}$/]

What the hell was being thought when that was wrote?

If you wish to submit a comment, you must be a registered member and logged in.

Login or Register.



Return to Category Selection

 

Who Visited EnigmaGroup Today?

1389 Guests, 222 Users (218 Spiders)
modded-account, Galagatron, tgm001, junaid_junaid59, famous0123, mjneat, Aska, Beat_Slayer, Molinaro, M0rdak, plex, Ausome1, dark_void, Imre, TheCheeseDemon, rockcraft, Vreality2007, mmndglxuwn, m0rt, unholyblood, psychomarine, iterrumzz, VurbTrurb, CJ_Omaha, Mayonoula, MAMWOURBROR, mutabor, gobinda, cossyDrybrich, Razin, zaCruBumas8, hunja, johny34, ssmaslov, pantoufle, bagy, arctica, hackarchives, UsedDeteKef, Peculator, Fadhilat606, TheTrueMonarch, Pascall01, hackaday, Tjm, arndevil, flairvelocity, lol, alphbond, kdivanov, elizbethallis6, Rik, bn11, BorgBot, SHASHANK101hello, 4poc4lyptic, ksajxai, nbmorri1, electro-technic, saraf, شمالي عرعر, lamb, AutobotPrime, Underleaf, The End, tomtombomb, killobyte, snowgirlx, so_saucey, zerolife, Althor, Cramps, Hekser, Hyperborn, cyber-guard, jhgrunn, cobra, Partisan, MAZI_, cyborg, GenbreedX, moel77, cliptoX, pwnpwnlolz, letshavepie, Mrwormz, yshiau, mirmo, roozyoppomo, soft_devil, cls777, scoobywan, Reiversed, joshua, st3alth, Afrika, PaiffDryday, venter, Anthony12796, sh3llcod3, 8FIGURE, Rannim, Evil1, maloaboy, BACanON, SlayingDragons, Repuhlsive, IvanDimitriev, lolzsec, 1RiB, mzungudo, Micro_Geek, iMaxx, aciboummamymn, k0unterkulcher, somebody777, m14m16, GoododotAlcob, negasora, Rastii, UninueMem, JohnJohnJohn, Swifsolja, ad.conquest, ngolatkar, Infinity8, Jigoku, thesupervisor, p0is0n5ting, kernel_mod, AKL, GothicLogic, themastersinner, dnatrixene135, ChewBigRed, kalak55, sejem, cve916, pollolololo, triecturn, Violatedsmurf, Ops, jmp, xsiemich, generalisimo, strudels, Dregoon, ga3ttpom, KingOfBritains, epoch_qwert, suten, FriskyKat, Ryuske, Adonis Achilles, ubqbcdzzhf, 3vil, Nightraven, US£RNAM£, Weindittewcon, Batesheelocot, GSmyrlis, MaxMeier, Elite.America, rabbidmind, Psiber_Syn, phoenix22, imittyerrotte, peewster, cyberturtle, ctb, dexgeda, sdw, Pizza, White_widdow, devarian, finesse, Nature112091777, Danc7171, Alphadragon, Estadagause, 53QR10U5, Xargos, Alkomage, hardlock, Barry Gonzoles, MineDweller, Gkjt, N4g4c3N, [I]nfectedbug, wimsteege, aqr5zdcw, xin214, Bugshuppy, SnoopSky, Hessesian, voodooKobra, sKcarr, IROverRated, W1F1G3NJU75U, Baddy, Patrickk, ziadmosaan, gamble86, realzs, CruelDemon, Shinju, aVoid, aquiredanonymity, kukumumu, web_request, callmeneon, KissMyDAFFODIL, Feld Grau, Abhinav2107, prabhataditya, mbuyiselo, shumer, phenom216, princennamdi, huskyboiza, ninety-nine, lucca65
 
Enigma Group