[Solved] How to remove numbers from string which starts and ends with numbers?

[ad_1] simple using replaceAll() using ^\\d+|\\d+$ regex that looks for digits in the beginning and ending of the line. System.out.println(“1adfds23dfdsf121”.replaceAll(“^\\d+|\\d+$”, “”)); output: adfds23dfdsf EDIT Regex explanation: ^ Start of line \d+ Any digit (one or more times) | OR \d+ Any digit (one or more times) $ End of line 3 [ad_2] solved How to … Read more

[Solved] I want to find all words using java regex, that starts with “#” and ends with space or “.”

[ad_1] This one should be the way: #(\w+)(?:[, .]|$) # matches # literally \w is a word with at least one letter (?:) is non-capturing group [, .]|$ is set of ending characters including the end of line $ For more information check out Regex101. In Java don’t forget to escape with double \\: String … Read more

[Solved] regex pattern to find example url from string [closed]

[ad_1] As Marty says, it all depends on which language you are using. You could do it in JavaScript, like so: var myString = “i have a example link:- https://www.google.co.in/search?q=web+service+urls&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb&gfe_rd=cr&ei=ex5iU-6CLMeW8QezvoCgAg i need a regex to extact that full url from text string. thanks!”; var myRegexp = /(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/ var match = myRegexp.exec(myString); alert(match[0]); Here’s a demo … Read more

[Solved] JavaScript : Find (and Replace) text that is NOT in a specific HTML element?

[ad_1] If, and only if, there are no nested <span>-tags, you can search for /(<span\b[^>]*>[\s\S]*?<\/span>)|(\b(?:foo|bar)(?:\s+(?:foo|bar))*)/g and replace it with the function function matchEvaluator(_, span, word) { if (span) return span; return ‘<span class=”widget”>’ + word + ‘</span>’; } the part (<span\b[^>]*>[\s\S]*?<\/span>) searches for the span element. That’s the part, where no nested <span>-element is allowed. … Read more

[Solved] Clean Urls with regular expression

[ad_1] Use the replace menu by pressing Ctrl+H, and make sure regular expressions are enabled. Then, Find (^.*\/).* and Replace $1: https://regex101.com/r/lJ4lF9/12 Alternatively, Find (?m)(^.*\/).* and Replace $1: https://regex101.com/r/lJ4lF9/13 Explanation: Within a capture group, Find the start of the string (^) followed by anything any number of times (.*) until the last “https://stackoverflow.com/”, then anything … Read more

[Solved] Javascript split function to split into array at new line or white space [closed]

[ad_1] To split on any whitespace (including newlines), you’d use /\s/ with split: var theArray = theString.split(/\s+/); \s means “spaces” (e.g., whitespace — including newlines), and + means “one or more“. To trim whitespace from the beginning and end of the string first, on any modern browser you can use String#trim: var theArray = theString.trim().split(/\s+/); If … Read more