|
I am using Notepad++
Thank you for pointing that out, I was not aware and I have comply to the forum common rules.
What is expected is:
1. a string like this to be matched:
Abc 2:5a; 24:51d, 53; 1:9b, 22-23c; 1:22-23, 9; 1:22-23, 24-25;
2. this string should not be matched if it is found at the start of a line, that is, a new row; only in the middle o at the end of a row.
3. if in the middle or at the end of a string/row, it should match only if it starts with capital letter. E.g. Abc, not abc
4. After matching the Replacing I need is like this:
Abc 2:5a; Abc 24:51d, 53; Abc 1:9b, 22-23c; Abc 1:22-23, 9; Abc 1:22-23, 24-25;
I hope I was more clear this time.
I welcome any perfecting, because reading regex is indeed pain enough. So, I should be very accurate.
Thank you, sir!
-- modified 14-Jun-21 5:31am.
|
|
|
|
|
You're welcome - it's not "forum common rules", it's just common sense - we only get exactly what you type, so the more accurate your question, the better the answer.
To be honest, I wouldn't faff too much with a regex - use it to extract the basics, and then use your presentation language string handling to break the rest up. You'll end up with much more readable code, and given the "vagueness" of your description, it's very likely that something will change or have been forgotten.
It's a lot easier to maintain PL code than a complicated regex!
I'd also suggest that you get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Greetings Dumitru, Im not expert because there seems to be many different flavors, so Im just guessing on this.
But it does seem like each "semicolon-comma pair" could be represented by something like ...
(\d{1,2}(?:[-:]\d{1,2}[a-z]?)?; )(\d{1,2}:\d{1,2}(?:[a-z]|-\d\d)?, )
So depending on your flavor, since the sample has 4-1/2 pairs, you might have to type a VERY long string like...
^([\w]+\. )(\d{1,2}(?:[-:]\d{1,2}[a-z]?)?; )(\d{1,2}:\d{1,2}(?:[a-z]|-\d\d)?, )(\d{1,2}(?:[-:]\d{1,2}[a-z]?)?; )(\d{1,2}:\d{1,2}(?:[a-z]|-\d\d)?, )(\d{1,2}(?:[-:]\d{1,2}[a-z]?)?; )(\d{1,2}:\d{1,2}(?:[a-z]|-\d\d)?, )(\d{1,2}(?:[-:]\d{1,2}[a-z]?)?; )(\d{1,2}:\d{1,2}(?:[a-z]|-\d\d)?, \d{1,2}(?:[-:]\d{1,2}[a-z]?)?;)$ With a replacement like...
\1\2\1\3\4\1\5\6\1\7\8\1\9
modified 5-Oct-21 21:01pm.
|
|
|
|
|
I want to match exact strings with a vertical bar and square brackets, but I want to match the shortest possible.
Meaning, I want to match the string
[aaa|bbb]
not anything in this
[aaa] | [bbb]
or this
[aaa] | [aaa|bbb] (in this example, I only want [aaa|bbb], and want the the first [aaa] be ignored (not matched)
so I can't use the regex:
\[.*?\|(.*?)]
It can have non-alphabetical chars, like this [aaa|(ccc)bbb], or be in different languages.
What can I do?
|
|
|
|
|
How about:
\[[^\]]*\|[^\]]*\] This will match:
It will not match:
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Doesn't seem to work.
Using this engine it only matched the first line:
a [aaa|bbb] b
a [aaa|bbb] b
[|bbb]
[aaa|]
[|]
[aaa]
[aaa]|[bbb]
|
|
|
|
|
That site finds all five matches for me.
Demo[^]
Screenshot[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Needed to turn on the global flag...
Thank you!
|
|
|
|
|
Hello,
I would like to process a regex to look for only the internal links containing the rel="noopener"
For example search for this link:
<a href="https://www.linkinterno.it/2018/10/titolo/" target="_blank" rel="noopener"> anchor text </a>
In this case the regex should be:
href="https://www.linkinterno.it(.*?)rel="noopener"
and it should work as I checked it with the following regex test:
https://www.freeformatter.com/regex-tester.html
However, I am not looking for internal links correctly, only those with rel="noopener". How can I solve?
Thank you
|
|
|
|
|
Try this
href="https:\/\/www.linkinterno.it.*rel="noopener"
I had to escape the forward slashes '/' to try it in some of the regex testers so depending on the flavour of regex you are using you may need to remove them.
|
|
|
|
|
Thanks a lot
So, the concept is to find out if inside an href there is the site name (so that I can understand that it is an internal link) and that it contains the rel="noopener".
I have adapted the regex to the best, modifying it like this:
www.sito.it. * rel = "noopener"
and removing the https: // protocol which can generate errors.
Unfortunately, however, something is still wrong. I state that the regex I need for a seo spider (ScreamingFrog), in which it is possible to set the targeted regex for searches within a website.
I await your clarifications on this.
Thanks a lot
|
|
|
|
|
Without knowing what the internal link actually looks like it is difficult to help.
Assuming that an internal link looks like this
href="/2018/titolo"
You could try this
.*href=("https:\/\/www.linkinterno.it|"\/).*(rel="noopener").*
You would obviously have to check the first group to see if the 'https://'www.linkinterno.it"' was matched or just the '/' and then look at the second group to see if the rel="noopener" was matched.
|
|
|
|
|
Thanks for the reply,
I tried but all links containing rel noopener are searched. I'm interested in searching for internal links only, and can be recognized by the name of the site in the link. For example, if the site is https://www.sitoprova.it, in href there must be the name of the site at the beginning of the link, i.e.
|
|
|
|
|
With the sample text-strings you've provided, its impossible for any expression to match by 'internal' domain.
If your application has a %variable% to represent the domain being searched, you would have to provide this.
Regex simply matches text, it cant determine if that text is "the domain being searched" by your application.
I've seen apps that support variables like %domain% in their match-expressions, but they're specific to that application.
So if your app supports this, you'd have to look up the variable-name in the documentation, to provide a working example.
Short of that, you would need to either hard-code the domains per site being searched, like in the example provided.
Or include a larger snippet of the html, but only if the html offered another way to verify 'internal' (highly unlikely).
Sorry for the news, but regex wont solve this without 'internal' being defined, whether by a previous match, or by some variable.
Some apps even let you customize variables, so maybe thats another option? Sorry, but I know nothing of this "Screaming Frog".
Either way, I do wish you luck!
modified 5-Oct-21 21:01pm.
|
|
|
|
|
What can be the RegEx for matching all spaces in quotes but not quotes..
Example: "This is testing text"
My RegEx: (?<=\")\s+(?=\")
The above RegExp is not matching all spaces..
|
|
|
|
|
The \s+ in that regex will only match a single string of one or more consecutive whitespace characters, not "all spaces"
So your regex would match "This test" or "This test" but not "This is testing"
There are lots of online regex builders and analysers, which I suggest you seek out.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Sorry,
do you suggest me a regex to find in a page not properly closed href tags, like this?
<a href="https://www.sito.it/" target="_blank" rel="noopener"property</a>
In practice, the final ">" is missing. Can you suggest a regex that can detect this?
Thanks and good job
|
|
|
|
|
|
Ok Richard,
thaks a lot
|
|
|
|
|
|
|
The commonest way that people solve this for browsers that don't support this is to think in reverse. In other words, you reverse the string and the regular expression so that all you end up testing is the negative regular expression, rather than a lookbehind. This[^] is a great resource.
|
|
|
|
|
My Customer number is in the pattern : 88765
ie. 5 digits alone...
using regex i have to validate if there are any characters and special characters in the customer number. Incase there are any characters (eg: 8AB90) or special characters then my string is invalid.
Please help me with the RegEx for the same.
|
|
|
|
|
poornima sadasivan wrote: validate if there are any characters and special characters in the customer number. An easier way it to check to make sure all characters are numbers. This uses LINQ. For example:
return strVar.All(char.IsDigit);
|
|
|
|
|
Following should do it in perl, java and C#.
^[0-9]{5}$
|
|
|
|
|