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]+)
Related
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
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
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
How would I match the two numbers before the word "min"
Sample string:
15min
I would want to match:
15
Edit:
I've tried matching the pattern, but how do I get the two characters before?
\W*((?i)min(?-i))\W*
Here's a regex that just extracts the first number in the string:
^\D*(\d+).*$
If the number must be in front of min, then you can write it as:
^\D*(\d+)min.*$
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 tried many alternatives but I am not reaching anywhere
/^[5]\d{9}$
can someone help.
Your regex must be like below,
^5\d{8}$
You mean this?
/5[0-9]{8}/
First a five, and then 8 times a digit.
If you want it to match anywhere, use this
/5\d{8}/
If you want it to be on a line by itself, use this instead
/^5\d{8}$/
The caret (^) means it must occur at the start of a line, and the dollar ($) means it must occur at the end of a line.
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.