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 6 years ago.
Improve this question
I want to ask about read the regex pattern. I have a regex pattern
"/^[ \t]*\/\*<O$firstline>\*\//,/^[ \t]*\/\*<\/O$firstline>\*\//s/\/\///g" $Path/DebugVersion.c
How should I read this pattern? I need an explanation about this regex. If anyone can explain this to me you can reply this questions. I'm thankful if you answer this question.
Regard,
Gustina M.S
This actually looks like a sed expression, and it consists of two regular expressions expressing a range, and another regular expression in a search/replace command. The basic structure of the command is:
/START_EXPRESSION/,/END_EXPRESSION/ COMMAND
Where START_EXPRESSION and END_EXPRESSION are both regular expressions, and COMMAND_EXPRESSION is a sed command that will execute for every line in between those two expressions (inclusive).
Just to make it clear, the range expression is:
/^[ \t]*\/\*<O$firstline>\*\//,/^[ \t]*\/\*<\/O$firstline>\*\//
Or, splitting that up a little more:
START_EXPRESSION: /^[ \t]*/**//
END_EXPRESSION: /^[ \t]*/*</O$firstline>*//
And COMMAND is s/\/\///g.
The link that a commenter provided to https://regex101.com/ should help you understand the individual patterns, and the sed man page will also be a useful resource.
Related
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 6 years ago.
Improve this question
I am student in the college and I need some help with recognition pattern of characters: what it will match ? or maybe somebody can explain how does it work ?
" (k[abc]*p)+ "
Thank you for any help.
This is a bit of a vague question as you're basically asking how regular expression work.
First of all I would recommend 'Mastering Regular Expressions' which is a pretty great O'Reily book on regex.
Also, for a regex playground, I really like to use Rubular (http://www.rubular.com/) as a playground, although this is meant for ruby, it can give you a good understanding into general regex expression and comes with a nice quick reference guide.
Taking some time to figure this out yourself will be very helpful, regular expressions are not going away.
In this case, your expression is evaluating everything inside the () as one chunk. So it's looking for a k, then at least one (+) of either abc ([abc]) followed by a p, at least one time (+).
So things like kap, kabcp will match.
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 7 years ago.
Improve this question
I'm using Notepad++ to look at a broken CSV that won't import.
The pattern should be:
"text","text","text","text","text","text","text","text",date
Is there a way in Notepad++ to find lines that do not match this?
^(?!"[^"]*"(?:,"[^"]*")*,[\d\/]*$).+$
Use a negative lookahead. See this regex101 demo.
One thing that might work, depending on what you want to do with the result, is to simply find and remove all the correct instances. This leaves you with the broken lines. If you do this in a copy, you can then use the result to search for exact matches and find the locations in the original file.
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 9 years ago.
Improve this question
I'm assuming this is pretty simple but I'm going round in circles
<img src="\/\/i1.ytimg.com\/vi\/sY1S34973zA\/mqdefault.jpg"
I need to extract the sY1S34973zA portion.
I'm using PHP.
Any ideas?
Steve
This should do it:
<img src="[^"]+\/([^"\/]+)\/[^"]*"
The folder name is captured and can be replaced as $1.
I'm a little confused by the backslashes. Are you saying the backslashes are part of the string, or are they simply escaping the forward slashes in whatever language you're using?
If the latter, you'll need to make an adjustment or two above.
You can use this lookahead based regex:
[^/]+(?=\/[^\/]*$
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am using a file search tool which can use regex to find files which contain certain text. My regex skills are pretty simple. (I am going to assume the file is treated like a single text with some line breaks)
Let's say I want to find files which contain these 3 words: route, boy & skill.
How to create two regex's, one to search for those words where each word needs to be a whole word (white space before or after, at beggining or end of line), and another regex where one or more words could be part of another word (like substring function)?
Update
I am not interested in regex tutorials and testers. If I need one, I certainly can google for one and find dozens. This is a regex that I simply can't create but which I will use over and over in that tool. Maybe regex doesn't support what I want and a regex expert can tell me that's the case. So no amount of regex tutorials and testers is going to help. I appreciate the links but they are not going to help me here.
Try following regular expression:
(?=.*\broute\b)(?=.*\bboy\b)(?=.*\bskill\b)
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 8 years ago.
Improve this question
i need some help. My data;
{foreach $page_list as $page}
<li>{$page->name}</li>
{/foreach}
And my pattern;
~\{foreach\s\$(.+)\sas\s\$([^\{]+)\}([^\{]+)\{\/foreach\}~
But it's not working. What is wrong ?
The pattern with which you are trying to exclude the line between the two {foreach...} regions explicitly does not match '{' characters, but two are present in the string. Since that middle area's match is broken somewhere that doesn't get followed by a {/foreach}, the entire pattern fails to match.
That entire portion of the pattern should possibly be .* instead. Rely on backtracking to catch the closing {/foreach}. Of course, this will erroneously match an entire list as one thing, but regular expressions in general can't match quotes (without backreferences, which are technically non-regular and hurt performance), so you might need another parsing strategy entirely.