[Solved] how to write regex expression in java [closed]

[ad_1] The regex pattern would be: String configSting=”Rs|RS|rs|rupee”; String regEx=”(?:^|(?<=[^a-zA-Z]))(“+configSting+”)(?:(?=[^a-zA-Z] )|)”; Pattern stringPattern = Pattern.compile(regEx); [ad_2] solved how to write regex expression in java [closed]

[Solved] Why there are empty string while trying to split a string in Java? And how to fix it?

[ad_1] It’s because you’re splitting by a single character, you would have to do this eagerly: String[] Operators = stringNumbers.split(“[0-9.]*”); Or you can filter the results: String[] Operators = Arrays.stream(stringNumbers.split(“[0-9.]”)) .filter(str -> !str.equals(“”)) .toArray(String[]::new); 5 [ad_2] solved Why there are empty string while trying to split a string in Java? And how to fix it?

[Solved] find substring using match regex

[ad_1] Since this is not quite HTML and any XML/HTML parser couldn’t help it you can try with regex. It seems that you want to find text in form ?drug <someData> ?disease To describe such text regex you need to escape ? (it is one of regex special characters representing optional – zero or once … Read more

[Solved] Simple regex – parse Firstname Lastname, sex (male,female), age or birth year

[ad_1] You only want “name, sex, age(or YearOfBirth)” You still can use Regex for it, or String.Split: Split solution: string line = “Max Smith m 20″; string[] words = line.Split(” “); int nr = items[words.Length – 1]; //use number to determine age or year string gender = items[words.Length – 2]; //string name = combine the … Read more

[Solved] Remove all symbols different from numbers and letters in string [duplicate]

[ad_1] This should work: var result = new Regex(“[^a-zA-Z0-9 ]”).Replace(address, string.Empty); This keeps only whatever in a-Z, A-Z or 0-9 or white space You can also use linq: var result2 = new String(address.Where(x => char.IsLetterOrDigit(x) || char.IsWhiteSpace(x)).ToArray()); 4 [ad_2] solved Remove all symbols different from numbers and letters in string [duplicate]

[Solved] Getting the substring after a character in C# using regex

[ad_1] In C#, use Substring() with IndexOf: string val = val.Substring(val.IndexOf(‘]’) + 1); If you have multiple ] symbols, and you want to get all the string after the last one, use LastIndexOf: string val = “[01/02/70]\nhello [01/02/80] world “; string val = val.Substring(val.LastIndexOf(‘]’) + 1); // => ” world ” If you are a … Read more

[Solved] Write regular expressions [closed]

[ad_1] I would suggest something like this: /\) (?!.*\))(\S+)/ rubular demo Or if you don’t want to have capture groups, but potentially slower: /(?<=\) )(?!.*\))\S+/ rubular demo (?!.*\)) is a negative lookahead. If what’s inside matches, then the whole match will fail. So, if .*\) matches, then the match fails, in other terms, it prevents … Read more

[Solved] Getting string between exact letters by regex in Swift

[ad_1] As per my comment, this is a task for DateFormatter rather than RegeX. I threw this together in a playground quickly to demonstrate what I mean. let inFormatter = DateFormatter() inFormatter.locale = Locale(identifier: “en_US_POSIX”) inFormatter.dateFormat = “yyyy-MM-dd’T’HH:mm:ssZZZZZ” let input = “2019-03-11T17:04:00+0100” let dateFromInput = inFormatter.date(from: input)! // This should be unwrapped properly in your … Read more