TCL - Fetch string between strings [closed] - regex

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
I have a large chunk of data and would like to extract a value of a particular field using TCL regexp.
ip="1.2.3.4" protocol="SFTP" username="abcd"
Need to extract the word SFTP without double quotes, the former and later fields can be ip,username or something else. So regexp has to use the word protocol as reference.

In this case, I'd use:
regexp {\yprotocol="(.*?)"} $theString -> theProtocol
However, if this is parsing XML then I'd actually use an XML handling extension like tDOM.

Related

How can I check if user input contains a letter? [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 2 years ago.
Improve this question
In Ruby, I want to see if user input contains any letter in the alphabet.
I have tried using contains and include?, but neither of these worked.
See String#include?
For example:
myString.include? 'a'
Similar to the comment from Cary: use a regular expression (regexp):
puts ‘matches’ if in_str =~ /[A-Za-z]/
See also: https://ruby-doc.org/core-2.7.1/Regexp.html

How to use regex to pull out a specific value in classic asp [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 3 years ago.
Improve this question
I can't figure out a way to pull out two numbers in a string and save them in a different variable in classic asp.
The string is:
"\1800_411.pdf.log"
All I was trying to do is to save the first number which is 1800 in a variable and save the 411 in a different variable
What about:
(\d+)_(\d+)
This would save them into two capturing groups. See here: https://regex101.com/r/v83Zbt/1

How to pass a string into glutCreateWindow() function? [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 3 years ago.
Improve this question
I am reading a name from a file which I then use to name the window. However, it will not allow me to do that since it requires an ASCII character string . I can however do something like this directly
glutCreateWindow("StackOverflow").
Isn't this also a ASCII character string? Why am I able to do this but not something like this:
string x = "stack";
glutCreateWindow(x);
Is there a way to cast "x" to meet my needs?
Use the std::string::c_str() method:
std::string x = "stack";
glutCreateWindow(x.c_str());

Regex - finding strings between signs [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
I was trying to solve this by myself but there are only solutions for cases like that:
"text" "text2" "text3"
I need to write a pattern which takes strings starting with '-' sign, expected result is shown below:
Input:
-something/3443/kk-somethingelse/111/333/zz
-text/ff/33/33/zz
Output:
1. something/3443/kk
2. somethingelse/111/333/zz
3. text/ff/33/33/zz
as individual grups.
Thanks in advance and sorry I couldnt manage that.
Try this pattern, with global flag:
-([^-\s]+)
Demo link
I would exclude line breaks as well:
-([^-\r\n]+)

Finding first five digits in a var with Regex [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
I have a variable that looks like this: AF1400006
I want to use regular expressions in order to return the number "14000".
I have gone through many threads here, but none quite seems to get me anywhere.
Thanks!
EDIT:
I don't see what's up with the downvotes, isn't this a forum for asking questions?
Anyhow, I solved my problem now, thanks for the help :-) For those wondering, I used it in a scanning software called Drivve Image to use parts of a barcode on a document as the name of the output folder. The software uses a unique regex formatting which seemed to be my issue.
You would need to use something like \d{5} which will match 5 digits.
Depending on the language you are using you would then access whatever the group matched.
For instance, in Java:
String str ="AF1400006";
Pattern p = Pattern.compile("\\d{5}");
Matcher m = p.matcher(str);
if(m.find())
System.out.println(m.group());
Which yields the number you are after.
An example of the expression is available here.