[Solved] Need the words between the ” – ” ONLY string splitting [duplicate]

So basically you to first split by – and then each side by a non-word character. Therefore you can try: String s = “ABC_DEF-HIJ (KL MNOP_QRS)”; String[] splits = s.split(“-“); // {“ABC_DEF”, “HIJ (KL MNOP_QRS)”} String[] lefts = split[0].split(“[^a-zA-Z]”); // {“ABC”, “DEF”} String[] rights = split[1].split(“[^a-zA-Z]”); // {“HIJ”, “”, “KL”, “MNOP”, “QRS”} String string1 = … Read more

[Solved] In C++ why does reference to single character of std::string give a number [closed]

On my Debian/Sid/x86-64 the below program (in source file itsols.cc compiled with the command g++ -Wall itsols.cc -o itsols) #include <iostream> #include <string> int main(int, char**) { std::string s = “Hello”; std::cout << s[3] << std::endl; return 0; } displays a single lower-case l (compiled with g++ -Wall itsols.cc -o itsols, both with GCC 4.7.2 … Read more

[Solved] How take the string between two symbols c#? [closed]

I’m not sure if this matches what you need but you could try: var myString = “!re=.id=2CB=name=xxname123=service=vpn=caller-id=”; var match = new Regex(@”\.id=(?<value>[^=]*)=”).Match(myString); var id = match.Groups[“value”].Value; I haven’t tested this for specific syntax, but that should get you just that captured string. You can modify that to iterate across a MatchCollection if you need to … Read more

[Solved] Replacing a substring with given form with another in C#

Basically: take the pattern (containing 3 groups), replace instr with second group from pattern. private string MyReplace(string inStr, string leaveStr) { string pattern = @”(.*?)(” + leaveStr + “)(.*)”; string repl = @”*$2*”; Regex rgx = new Regex(pattern); return rgx.Replace(inStr, repl); } string x = MyReplace(@”\textbf\{atext\}”, “atext”); x = MyReplace(@”\textbf\{1\}”, “1”); full string – group … Read more

[Solved] Using substring in line C# [closed]

It means that the values you are passing to Substring are not valid for the string they are being called on. For example: string s = “hello”; string x = s.Substring(0, 1); // <– This is fine (returns “h”) string y = s.Substring(1, 3); // <– Also fine (returns “ell”) string z = s.Substring(5, 3); … Read more

[Solved] Issue with substr C++

As mentioned you can’t call substr() with a std::ifstream. What you probably meant was to take the parts from the line string read in a[i]= stoi(line.substr(4,2)); name[i]= line.substr(18,15); b[i]= stoi(line.substr(36,1)); Also note you’ll need to convert the substrings extracted to a number (instead of assigning them directly), hence I have added the stoi(). As also … Read more

[Solved] How do I remove all strings containing digits before “hs” like “18hs” from a list of strings? [closed]

>>> import re >>> words = [“hello”, “18hs”, “18aaa”, “21hr”] >>> [w for w in words if not re.match(r’\d+h’, w)] [‘hello’, ’18aaa’] This loops over the list and keeps the items that don’t match the regex \d+h, which means “one or more digits followed by an h”. If you need to keep strings like 7hg, … Read more

[Solved] JavaScript taking information from a email address

First get the email address to parse. You’ve already done that. Here, x contains the email address. var x = document.getElementById(“myText”).value; Now you can use x.indexOf(“.”) to get the position of the first period. Likewise, use x.indexOf(“@”) to get the position of the “@” symbol. These two values are passed to x.substring() to get the … Read more

[Solved] How to substring from character to end of string?

A crude but working example. you can further improve upon it. Call GetEverythingFromThird(“https://stackoverflow.com/questions/ask”, “https://stackoverflow.com/”); The method: static string GetEverythingFromThird(string instring, string checkitem) { string outstring = “”; //1st occurence int index = instring.IndexOf(checkitem); outstring = instring.Substring(index + 1); //2nd occurence index = outstring.IndexOf(checkitem); outstring = outstring.Substring(index + 1); //3rd occurence index = outstring.IndexOf(checkitem); outstring = … Read more