I want a partner for preg_split for multiple matches. For example
preg_split('/(.be|.fr|.im|.fi)/i', $input[$i], -1, PREG_SPLIT_DELIM_CAPTURE);
I tried something like this but doesnt work. I want for example to search for these
5 strings and if it finds them split the string there. Anyone know?
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
What did not work ? Give an example of what you want to happen, and what does happen. Did you get an error ?
D4n1sD 0 Light Poster
What is happening is the strangest thing ever, the strangest thing I ever had while coding I dunno how to explain it. Here is the source
$text=$_POST['comments'];
function ValidateEmail($email) {
$valid = true;
$findats = strrpos($email, "@");
if (is_bool($findats) && !$findats) {
$valid = false;
}
else {
$domain = substr($email, $findats+1);
$local = substr($email, 0, $findats);
$locallength = strlen($local);
$domainlength = strlen($domain);
if ($locallength < 1 || $locallength > 64) {
$valid = false;
}
elseif ($domainlength < 1 || $domainlength > 256) {
$valid = false;
}
elseif ($local[0] == '.' || $local[$locallength-1] == '.') {
$valid = false;
}
elseif ((preg_match('/\\.\\./', $local)) || (preg_match('/\\.\\./', $domain))) {
$valid = false;
}
elseif (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
$valid = false;
}
elseif (!preg_match('/^(\\\\.|[A-Za-z0-9_.-])+$/', str_replace("\\\\","",$local))) {
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) {
$valid = false;
}
}
}
if ($valid) {
return 1;
}
else {
return 0;
}
}
function explodeX($delimiters,$string)
{
$return_array = Array($string);
$d_count = 0;
while (isset($delimiters[$d_count]))
{
$new_return_array = Array();
foreach($return_array as $el_to_split)
{
$put_in_new_return_array = explode($delimiters[$d_count],$el_to_split);
foreach($put_in_new_return_array as $substr)
{
$new_return_array[] = $substr;
}
}
$return_array = $new_return_array;
$d_count++;
}
return $return_array;
}
$input=explodeX(Array("!"," ","#","$","%","^","&","*","(",")","=","+","{","}","]","[",";",":","'","\\","\"","|",",","/","?","<",">"),$text);
$i=0;
while($i<count($input))
{
$final=preg_split('/(.be|.fr|.eu|.com|.me|.net|.org|.info|.biz|.pro|.cc|.tv|.mobi|.tel|.am|.fm|.mu|.nu|.name|.it|.li|.lu|.ch|.nl|.me.uk|.co.uk|.org.uk|.de|.at|.re|.es|.pt|.pl|.cz|.cx|.gs|.tl|.cat|.cn|.tw|.ht|.ie|.us|.lv|.lt|.im|.fi)/', $input[$i], -1, PREG_SPLIT_DELIM_CAPTURE);
$d=0;
while($d<count($final))
{
echo $final[$d]."<br>";
$d=$d+1;
}
$i=$i+1;
}
There are some non used variables etc that I used them for some tests etc dont pay attention to them. What I want to do is to search within strings
e-mail adresses and print them. For example u enter [email]adlkasdlak@asdas.com[/email] [email]wdawkda@kdasda.com[/email]; <dwadawdawdaw@dasdad.com> [email]adawdawdwd@dasdadwaw.comawdwadwdw@dasda.com[/email]
things like that.
However when I input one single e-mail it works fine but when putting huge strings I
get CRAZIEST outputs ever. Example
jurwloj.1982@lovw.fr jurwloj.1982@lovw.fr To: gjut.jnnw@hotmjol.fr; crys_20@hotmjol.com; crys_20@hotmjol.com; koffwn-21@hotmjol.fr; mjswbj@cwgwtwl.nwt; wlyjzonj@hotmjol.fr; kjronwmso@hotmjol.fr; lwsgrosswspowrrws@hotmjol.fr; mjrojnnwcjndotto@hotmjol.fr; do-dou89@lovw.fr; nonowg39@hotmjol.fr--* to@gmjol
while inputing this string it will split [email]jurwloj.1982@lovw.fr[/email] [email]jurwloj.1982@lovw.fr[/email]
into different pieces like ju rw loj.1982@ lo vw .fr
while all the next e-mails
will be outputted normally. And some of them might get splited aswell its really confusing. If u have msn plz give to me I might be able to show you.
Edited by mike_2000_17 because: Fixed formatting
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.