[Solved] How to replace the string [closed]

I think using Regular Expression works better. private static String setSize(String htmlString) { String reg = “size=”[0-9]+””; Pattern pattern = Pattern.compile(reg); Matcher matcher = pattern.matcher(htmlString); while (matcher.find()) { String sizeString = matcher.group(); pattern = Pattern.compile(“[0-9]+”); Matcher numMatcher = pattern.matcher(sizeString); if (numMatcher.find()) { String size = numMatcher.group(); int realSize = Integer.parseInt(size); int resultSize = realSize / … Read more

[Solved] Python Regex punctuation recognition

After minimizing your example we have: re.findall(r”/\,\b”, “/NN ,/, breeding/VBG Lilacs/NNP out/RB of/IN the/DT dead/JJ land/NN”) And it does not match for obvious reasons: there is no beginning of the word immediately after the comma. 2 solved Python Regex punctuation recognition

[Solved] How to get specific words from Word document(*.doc) using C#? [closed]

A simple approach is using string.Split without argument(splits by white-space characters): using (StreamReader sr = new StreamReader(path)) { while (sr.Peek() >= 0) { string line = sr.ReadLine(); string[] words = line.Split(); foreach(string word in words) { foreach(Char c in word) { // … } } } } Let me know, if you have any questions. … Read more

[Solved] Facebook profile page regex excluding dialog|plugins|like pages [closed]

Try this: it matches anything before and after “facebook.com” followed optional by “https://stackoverflow.com/” and not followed by “plugin”, “dialog”, “like” (.*)facebook\.com\/?(?!plugins)(?!dialog)(?!like)(.*) See this online example code (?!text) is positive lookahead regexp. You can read more about this here. 1 solved Facebook profile page regex excluding dialog|plugins|like pages [closed]

[Solved] Regex to return all attributes of a web page that starts by a specific value

A regular expression would likely look like this: /http:\/\/example\.com\/api\/v3\?\S+/g Make sure to escape each / and ? with a backslash. \S+ yields all subsequent non-space characters. You can also try [^\s”]+ instead of \S if you also want to exclude quote marks. In my experience, though, regexes are usually slower than working on already parsed … Read more

[Solved] Javascript Regex Conditional

Here’s a solution which uses non-capturing groups (?:stuff) which I prefer so I don’t have to dig through the result groups to find the string I’m interested in. (?:#)(?:[\w\d]+-)?([\w\d]+) First it throws out the # character, then throws out the stuff up to and including the – character, if it is there, then groups the … Read more

[Solved] How to get credentials from a String with many characters with substr and store them in variables

Here is a non Regex version of what you are trying to achieve. $str = “server_name::IMACW10\COZMOSQLEXPRESS @database_name::OneTwoThreePet username::pauline_pet databasePass::root”; $test = explode(” “, $str); $array = array(); foreach($test as $key){ $newkey = strtok($key,”:”); $array[$newkey] = substr($key, strpos($key, “:”) + 2); } list($server, $dbname, $username, $pass) = array_values($array); echo ‘$serverName=”.$server.”<br> $databaseName=”.$dbname.”<br> $username=”.$username.”<br> $pass=”.$pass; Output: $serverName=IMACW10\COZMOSQLEXPRESS $databaseName=OneTwoThreePet … Read more

[Solved] The c# of this JavaScript “regex replace”? [closed]

C# has a static method for matching for replacing a string treated as a pattern on the fly: text = Regex.Replace(Regex.Replace(text, @”[^>]+”, “”), @”[,:;()/&+]|–“, ” “); The Regex.Replace method automatically does a global replace. solved The c# of this JavaScript “regex replace”? [closed]

[Solved] Defining regular expression

I would use findall for this.. >>> import re >>> s=”AN : GSHJ488GL67 Customer : sh3893 Acnt No : cgk379gu Name : xyz” >>> re.findall(r’\b(?:AN|Acnt No) : (\w+)’, s) [‘GSHJ488GL67’, ‘cgk379gu’] Explanation: \b # the boundary between a word character and not a word character (?: # group, but do not capture: AN # ‘AN’ … Read more

[Solved] Replace a string in string that is in a List [closed]

Simple. Iterate over all strings inside List and then check if myString contains that or not. If yes, then replace it. foreach (string item in lst) { if (myString.Contains(item)) { myString = myString.Replace(item, string.Format(“$${0}$$”, item)); } } Also you can do same with LINQ: lst.Where(item=> myString.Contains(item)).ToList() .ForEach(item => myString = myString.Replace(item, string.Format(“$${0}$$”, item))); You can … Read more

[Solved] remove html input tag from string using C#

You could remove input tags from the string with a regular expression: var temp = “The accounting equation asset = capital + liabilities, which of the following is true. Ram has started business with 5,50,000 and has purchased goods worth 1,50,000 on credit <input type=”radio” id=’op1′ name=”q2option” value=”1″ /> a) 7,00,000 = 5,50,000 + 1,50,000 … Read more