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

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 solved How to remove numbers … Read more

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

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 str … Read more

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

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 I … Read more

[Solved] How to convert string to boolean condition in java/android?

Returning code from server is terrible awful. Anyways, this code I give you do some steps: removes new lines and multispaces into one length space from input. finds words by pattern where word starts with if and ends with digits. Adds them to array. prepares pattern with user chosen options combining into similar to (Q4a.NAOK==\”7\” … Read more

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

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. The … Read more

[Solved] Clean Urls with regular expression

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 any … Read more

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

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 you … Read more