Results 1 to 1 of 1
-
9th Feb 2011, 09:21 PM #1
Need help with designing a function to explode but ignore an escaped delimiter
Hello I think title should be self explanatory. I've coded this in php but need someone to adapt this to C#
PHP Code:function improved_explode($delimiter,$string,$escape=null)
{
$exploded = explode($delimiter,$string);
if($escape !== null)
{
// Fix exploded array to comply with escape char
foreach($exploded as $key => $value)
{
if ($value != '' && isset($exploded[$key]) )
{
if( stripos( $value.$delimiter, $escape.$delimiter) !== false )
{
// Merge $key and $key+1
$exploded[$key] = $exploded[$key] . $delimiter . ( isset($exploded[$key+1]) ? $exploded[$key+1] : '' );
// Fix $key
$exploded[$key] = str_replace( $escape.$delimiter , $delimiter , $exploded[$key]);
// Unset $key+1
if( isset($exploded[$key+1]) ) unset($exploded[$key+1]);
}
}
}
unset($key, $value);
// Fix array keys
$i = 0;
$new = array();
foreach($exploded as $key => $value)
{
$new[$i]=$exploded[$key];
$i++;
}
unset($key, $value);
$exploded = $new;
}
return $exploded;
}
NewEraCracker Reviewed by NewEraCracker on . Need help with designing a function to explode but ignore an escaped delimiter Hello I think title should be self explanatory. I've coded this in php but need someone to adapt this to C# function improved_explode($delimiter,$string,$escape=null) { $exploded = explode($delimiter,$string); if($escape !== null) { // Fix exploded array to comply with escape char foreach($exploded as $key => $value) { Rating: 5Trusted: Dom, l0calh0st, 0ccul7, robert420
Find all threads started by NewEraCracker
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Need Vps that ignore DMCA
By chandu4money in forum Hosting DiscussionReplies: 20Last Post: 4th Jan 2011, 04:50 PM -
Sud i Remove this or Ignore Him?
By umang in forum Legal IssuesReplies: 21Last Post: 19th Dec 2010, 02:51 PM -
An Ignore Mod
By WarezFreaks in forum IP.BoardReplies: 2Last Post: 14th Aug 2010, 05:46 PM -
delimiter.us
By accyuklad in forum Hosting DiscussionReplies: 1Last Post: 12th Jul 2010, 07:03 PM
themaCreator - create posts from...
Version 3.53 released. Open older version (or...