Re: [PHP] Regular Expression

2001-04-18 Thread Jeroen Geusebroek


oops. The expression should read '/\[([^\]]+)\]/'

Thanks all, i used this code and it works:

preg_match("/\[(.+)\]/",$msg_array[$i],$segments);
$title = trim($segments[1]); 
$description = ereg_replace("\[ $title \]", "", $msg_array[$i]);

Does anyone know a good regex tutorial? I'll probably bump into it again.
Regex'es seem to be very usefull.

Regards,

Jeroen Geusebroek

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Regular Expression

2001-04-18 Thread Andrew Braund

LinuxSA http://www.linuxsa.org.au/  meeting a couple of days ago was
on regex, some notes are at;
http://www.fornax.net/regex2/
or part 1 at;
http://www.fornax.net/regex/

HTH
Andrew Braund

 -Original Message-
 From: Jeroen Geusebroek [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, 19 April 2001 06:25
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Regular Expression
 
 
 
 oops. The expression should read '/\[([^\]]+)\]/'
 
 Thanks all, i used this code and it works:
 
   preg_match("/\[(.+)\]/",$msg_array[$i],$segments);
   $title = trim($segments[1]); 
   $description = ereg_replace("\[ $title \]", "", 
 $msg_array[$i]);
 
 Does anyone know a good regex tutorial? I'll probably bump 
 into it again.
 Regex'es seem to be very usefull.
 
 Regards,
 
 Jeroen Geusebroek


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular Expression

2001-04-18 Thread Martín Marqués

On Jue 19 Abr 2001 00:23, Andrew Braund wrote:
 LinuxSA http://www.linuxsa.org.au/  meeting a couple of days ago was
 on regex, some notes are at;
 http://www.fornax.net/regex2/
 or part 1 at;
 http://www.fornax.net/regex/

Isn't there a place with printable versions?

Saludos... :-)

-- 
El mejor sistema operativo es aquel que te da de comer.
Cuida tu dieta.
-
Martin Marques  |[EMAIL PROTECTED]
Programador, Administrador  |   Centro de Telematica
   Universidad Nacional
del Litoral
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular Expression Help

2001-03-05 Thread Henrik Hansen

 I want to delete everything after a tab (or space) on each line of
 a text file and can't figure it out. 
 
 An example line is
 ARIA 5.19 -0.0625 -1.19 5.25 4.5 48.5 100300
 


you can explode on a tab $arrlines = explode("\t", $the_line);
then save $arrlines[0] from every line.

Don't know if it's the most optimal way but it works :)

--
Henrik Hansen


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular expression problems

2001-02-25 Thread Simon Garner

From: "Dan Watt" [EMAIL PROTECTED]

 Im trying to build a user login system, and when there is a new user, I
need
 to validate that they are usign using word characters ([0-9A-Za-z_] or
 \w)... I have TRIED MANY different regular expressions to test this, but
 none work. This seems so simple but I am missing something. I need a
 expression that returs true ONLY if ALL the characters match \w  Any
 help would be appreciated.




?php
$username = "johnny";

if (!eregi("[^A-Z0-9_-]", $username))
{
echo "username OK";
}
else
{
echo "bad username!";
}
?

Assuming you only want letters, numbers, underscores or hyphens. If you
really want \w you would need to use preg instead of ereg, and then you need
PCRE support in PHP. Or you could use ereg's character classes, I think the
pattern would look like: "[^[:alphanum:]]". However you are probably better
off using an explicit set of characters as I have shown, so that it is
obvious what is and is not allowed.


Cheers

Simon Garner



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular expression problems

2001-02-25 Thread Dan Watt

ok, that was my problem Was using ereg... All the places I read about
how to do regular expressions (book, online...) did NOT clarify that \w and
such would need preg.. Thanks!

""Simon Garner"" [EMAIL PROTECTED] wrote in message
022d01c09fa6$a2bbd460$[EMAIL PROTECTED]">news:022d01c09fa6$a2bbd460$[EMAIL PROTECTED]...
 From: "Dan Watt" [EMAIL PROTECTED]

  Im trying to build a user login system, and when there is a new user, I
 need
  to validate that they are usign using word characters ([0-9A-Za-z_] or
  \w)... I have TRIED MANY different regular expressions to test this, but
  none work. This seems so simple but I am missing something. I need a
  expression that returs true ONLY if ALL the characters match \w  Any
  help would be appreciated.
 
 


 ?php
 $username = "johnny";

 if (!eregi("[^A-Z0-9_-]", $username))
 {
 echo "username OK";
 }
 else
 {
 echo "bad username!";
 }
 ?

 Assuming you only want letters, numbers, underscores or hyphens. If you
 really want \w you would need to use preg instead of ereg, and then you
need
 PCRE support in PHP. Or you could use ereg's character classes, I think
the
 pattern would look like: "[^[:alphanum:]]". However you are probably
better
 off using an explicit set of characters as I have shown, so that it is
 obvious what is and is not allowed.


 Cheers

 Simon Garner



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular expression problems

2001-02-25 Thread Simon Garner

From: "Dan Watt" [EMAIL PROTECTED]

 ok, that was my problem Was using ereg... All the places I read about
 how to do regular expressions (book, online...) did NOT clarify that \w
and
 such would need preg.. Thanks!



No prob - yeah, \w is a Perl feature :)

(preg = PCRE = Perl Compatible Regular Expressions)



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] REgular expression....difficult is it?

2001-02-18 Thread Ifrim Sorin

The ? meta-character is used for matching zero or one occurence of the
preceding character , in this case , l .
T'his means that you'll match all words that begin with 'Wi' and continue
with one or zero 'l' .

HTH
Sorin Ifrim

- Original Message -
From: Dhaval Desai [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, February 19, 2001 7:23 AM
Subject: [PHP] REgular expressiondifficult is it?


 Hi!


 I am not able to understand this REgular expression.

 /Wil?/

 would match "Winnie", "Wimpy" "Wilson" and "William",
 though not "Wendy" or "Wolf".

 Howz taht..?


 Can anybody explain me please.

 Thank You!
 Dhaval Desai

 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail - only $35
 a year!  http://personal.mail.yahoo.com/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] REgular expression....difficult is it?

2001-02-18 Thread Brian White


At 21:23 18/02/2001 -0800, Dhaval Desai wrote:
I am not able to understand this REgular expression.

/Wil?/

English Translation: Find a string that contains "Wi" that may or may not
   be followed by "l".

In pure "does the string match?" terms, your example is equivalent to

/Wi/

would match "Winnie", "Wimpy" "Wilson" and "William",
though not "Wendy" or "Wolf".

Howz taht..?


Does that help?

-
Brian White
Step Two Designs Pty Ltd - SGML, XML  HTML Consultancy
Phone: +612-93197901
Web:   http://www.steptwo.com.au/
Email: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] REgular expression....difficult is it?

2001-02-18 Thread CC Zona

[rearranged back to bottom-posting order, for clarity]

In article 012901c09a35$7b64c640$[EMAIL PROTECTED], [EMAIL PROTECTED] ("Ifrim 
Sorin") wrote:

  I am not able to understand this REgular expression.
 
  /Wil?/

 The ? meta-character is used for matching zero or one occurence of the
 preceding character , in this case , l .
 T'his means that you'll match all words that begin with 'Wi' and continue
 with one or zero 'l' .

More than that, it'll match any string in which a capital 'W' is followed 
by a lowercase 'i'. For example:

"Don't you love Wile E. Coyote?"
"I'm Wigging Out."
"The password is 'KiWi'."
"The password is '123Wiked'."

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] REGULAR EXPRESSION

2001-02-03 Thread Richard Lynch

 I 'd like to have an input that contains only a to Z and space and
 - nothing else like numbers or whatever and also does not
start
 with space !
 till now with ur help i get the following :

 (!ereg("[a-zA-Z[:space:]-]", $name))

All those weird characters you typed are not ASCII, and are not valid to
just throw into a string like that.

You can maybe use Regex hex representations of them, but they aren't going
to be the same characters on many people's browsers anyway...

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] regular expression help

2001-01-25 Thread Jeff Warrington

In article 005801c08668$e0459070$0201010a@shaggy, "Jamie Burns"
[EMAIL PROTECTED] wrote:

I tried something like this and your examples worked:

$str = "tag element = \"value\" nextelement";

if (eregi("=[[:space:]]*\"([^\"]+)|=[[:space:]]*([[:alnum:]]+)",$str,$regs)) {
   print("yes - ".$regs[1].":".$regs[2]."br\n");
}

since the pattern has an 'or' (|), you have to look in either the second
or the third element of the array you use to store values from the ereg.

Jeff


 can anyone help me figure out a regular expression to find the value of
 a tag element?
 
 for example:
 
 tag element="my value"
 tag element=value
 tag element="my value" nextelement
 tag element=value nextelement
 tag element = "my value"
 tag element = value
 tag element = "my value" nextelement
 tag element = value nextelement
 
 so in each of the above i need to find either "my value" or "value"...
 
 i tried this but it wont work for every situation:
 
 ereg("element[ ]*[=][ ]*[\"]?([^\"]*)[ |\"|].*" ...
 
 thanks for your help - regular expressions are not my best area!
 
 jamie.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] regular expression

2001-01-15 Thread Christian Reiniger

On Monday 15 January 2001 09:03, Fai wrote:
 ^.+@.+\\..+$  This regular expression can check if the email address is
 valid. But it cannot validate the email address with two "@", does

I use this code:

/*
 * Check whether the supplied string is a
 * (syntactically) valid email address
 * Only does a very rough check. Checking for complete
 * validity is nearly impossible.
 */
function pbIsMailAddress ($Address)
{
// strip comments
while (preg_match ('/\([^()]*\)/', $Address))
$Address = preg_replace ('/\([^()]*\)/', '', $Address);

// strip leading/trailing whitespace
$Address = trim ($Address);

// check for basic form
return preg_match ('/^[^@]+@[\w-]+(\.[\w-]+)+$/', $Address);
}

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"Software is like sex: the best is for free" -- Linux Torvalds

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




<    1   2   3   4