Category: Regular Expression
-
How to replace string in parentheses using regex
PHP, Java and other languages provide replace all functionality to replace any character by any specific character. But REGEX is best method to replace or remove any specific value using pattern. Suppose, we have input string is $xyz = “This is my best (friend)”; and we want to remove words from “()”. So it so…
-
Javascipt: how to use nl2br function
In php we have a function to replace nl2br means new line to break format. but when we need this functionality in our javascript code then what we do? We can do by simply manner: function nl2br(value) { return value.replace(/\n, “”); } Above function will return the converted ‘\n’ to ‘‘. But above function has…
-
PHP: Regular expression to make linkable url in string
Are you looking for a regular expression to make clickable url in the string? Yes!, you will get your solutions here: echo preg_replace(“/http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/”, “$0”, $string); If you want to open url in new tab then : echo preg_replace(“/http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/”, “$0”, $string); Tweet This Post