Split a string to have individual quotes [closed] - python-2.7

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a string
abc = 'tea,coffee'
Want to split into ('tea','coffee')
I tried to split but the result is showing as double quotes in front and last
i am getting result as "tea','coffee"

#given string
abc = 'tea,coffee'
#splitting into array
result = abc.split(',')
#making tuple
tuple(result)
#printing result
print(result)
done!!

Related

RegEx Splitting to a List<string> [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
RegEx is a bit confusing to me and I have been at it for 3.5 hours on one line.
I have a string:
" Layer 1 Layer 2 Layer 3 Layer 4 "
I would like to split it up into a List and cannot get it to work.
I tried this and it was close but still not what I am looking to do:
List<string> lineWords = Regex
.Matches(line, #"[Layier_]*\s*\s*[1-9]")
.OfType<Match>().ToArray()
.Select(match => match.Value)
.List();
Where am I in error?
Thank you.
You didn't write it explicitly, but I assume, you are using C#.
Your code requires only minor corrections:
I changed the regex a little (compare).
ToArray() is not needed.
Instead of List() use ToList().
So the code given below works.
List<string> lineWords = Regex.Matches(line, #"[Layier_]+\s*[1-9]")
.Cast<Match>()
.Select(match => match.Value)
.ToList();

Extracting date from the format [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am struggling through this date extraction. I have a date like this
("D("yyyy-mm-dd")).
I want to get this "yyyy-mm-dd" and I cannot strip ("D(") this also because I have this format in other places so I tried like this
first searching the string but I am not sure if I am on right track
eg. intabc = istrdate.SearchSubString("D(");
so please suggest how can I get this value.
Input is
"(D(YYYY-MM-DD))"
OUTPUT that I want
(YYYY-MM-DD)
What i have done(not correct way I think )
intabc = istrdate.SearchSubString("D(");
you can use substr() and string::erase() functions in c++98
string str = "\"D(\"yyyy-mm-dd\")";
string result = str.substr(3);
result.erase(result.end() - 1)
result.erase(result.end() - 1)
if you are using c++11 you can also use string::pop_back() method.

Removing non-alphabetic characters in VBScript run from command line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I'm trying to remove all the non-alphabetic characters in a string in a VBScript that will run from the command line.
Here's what I have thus far:
Set wshShell = CreateObject("WScript.Shell")
Dim test
test = "Hello:, world!"
test = strClean(test)
WScript.Echo(test)
Function strClean(strVal)
Set objRegEx = CreateObject(“VBScript.RegExp”)
objRegEx.Global = True
objRegEx.Pattern = “[^A-Za-z\n\r]”
strSearchString = objRegEx.Replace(strVal, “”)
End Function
But I'm getting the following error:
my.vbs (8, 35) Microsoft VBScript compilation error: Invalid character
The quotes you're using are Unicode and are invalid.
You should replace them by ASCII ones.
This is a community answer from Slai's comment that doesn't want to write an answer.See this meta post for more info.

win32 application c++ if-else not working [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
http://pastebin.com/8YJ7LJYA
The code you can see if you klick on the link. if I enter 123 and 123 the msgbox wan´t appear. also with other passwords won´t work.
INPUT1 is defined to 100, so INPUT1 == 123 will never be true.
INPUT2 is defined to 101, so INPUT2 == 123 will never be true.
Consider using GetDlgItemText to fetch the text in textbox and lstrcmp to compare texts.

How to check the format of keyboard input for a Perl script? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
My Perl script just takes whatever you give as an input, and I want make it more robust by checking the pattern of the input string. My input string has to be in the format xxxxx-xxxx-xxxx. How can I check that?
$foo =~ /^.{5}-.{4}-.{4}\z/s
For example, this will repeatedly ask for the value until it gets a valid one.
my $foo;
while (1) {
print("Please provide foo (xxxxx-xxxx-xxxx): ");
my $foo = <STDIN>;
die("EOF\n") if !defined($foo);
chomp($foo);
last if $foo =~ /^.{5}-.{4}-.{4}\z/s;
print("Invalid input\n");
}