Jump to content

s1w

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

s1w's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank You! both of You enlighten me about greatly important thing, that i couldnt find in any documentation or so much commentaries, eg main php manual http://pl2.php.net/manual/pl/function.preg-replace.php - about, that PHP can also take function as replacer! ealrier it was obvious for me it was impossible. Both solves are working well, but i was affraid that i would have problem to implement either two to my code, finally i turned up that indeed thebadbad #2 wouldnt make trouble as pattern with function stored in array. If I want pkSML version that looks v clear for me, i would have to change preg_replace construction. <?php $replace = array('/[\[\{]/', '/[\]\}]/', //change parenthesis [] {} na () '/(.*)\.(.*)$/e', //format extension '/[^\w\s\(\)\-`\.,;\+=#&!]|'. //allow some strange chars in filename _ -() `,.;+=!&# '^[\s\.,;]*[!&\-#]+[\s,;!&\-#]*/', //format tolerable beggining '/^[\s\.,;]+|\s+(?=\s.)/'); //or cut, and finally shorten multiple spaces $with = array('(',')',"trim('$1').'.'.preg_replace('~[\W]~','','$2')",'_',''); printt ('file|'.preg_replace($replace,$with,$str).'|'); //own print for debugging ?> thanks for help
  2. Hello. My problem is about processing Regular Expressions (Perl-Compatible) as on img: i've tried a hundreds of patterns, and still nothing for #1 not working: '/\..+$/' '/\..+?$/' '/\..+?(?!\.)$/' \ yes, this is followed char, I only dont know if logic is not inversed by $ for #2 $replace = '/\.[\w\W]+$/'; $with = ''; preg_replace($replace,$with,$str); (without returning correct alphanumeric findings for now, but still not working) others: '/\.[\w\W^\.]+$/' '/\.[\w\W^\.]+?$/' '/\.[\w\W[^\.]]+?$/' '/\.[\w[\W[^\.]]]+?$/' '/\.[\w\W&&[^\.]]]+?$/' //&& working in java, but rather not in php '/\.(?:\w|\W)+$/' //or even without [] '/\.(?:\w?|\W?)+$/' first idea with returnings: '/\s*\.[(\w)\W^\.]+?$/' '/\.(?:\(w?)|\W?)+$/' $replacer = '\.$1'; anyone could help me with this? greetings michael
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.