What is the best way to remove all non-alphanumeric characters from the beginning and end of a line?
~~STRING~~ => STRING "STRING" => STRING **STRING** => STRING **STR**ING** => STR**ING
You can use:
$repl = preg_replace('#^\W+|\W+$#', '', $str)
trim($string, $charlist) should do the trick.
trim($string, $charlist)
$str = preg_replace('/^\W*(.*\w)\W*$/', '$1', $str);
Source: https://habr.com/ru/post/1489669/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1489664/exclusive-access-to-the-microphone-in-android&usg=ALkJrhhKKgBub2e6dDTXFVfVolLQPD5wZgImport data using numpy.loadtxt: without delimiters, but with a fixed column width - pythonHow to trim special characters from a string? - phpRuby on Rails / Bootstrap: dynamic data in modal - dynamicHow to make the "touchhesBegan" method work for a certain kind? - iosHow to sleep in firefox extension without using setTimeout? - javascriptIs sendfile () a function similar to linux-aio? - c ++TypeConverter format DateTime type output - c #How to increase the memory allocated by GlassFish? - javaAffect one list item - emacsAll Articles