Click here to Skip to main content
15,437,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
]I am little confused on how to use regular expression to find a sub string in string .
I know how to remove unwanted characters using regular expression , but I do not get how "match" works

I found few "tutorials" and so far no luck.

Here is my next tutorial I will try

Regular-Expressions.info - Regex Tutorial, Examples and Reference - Regexp Patterns[^]


I would appreciative if somebody recommends a source to answer my question.
Please no u-tube.

What I have tried:

Different tutorials and coding in C++
Posted
Updated 7-Jul-22 16:12pm
Comments
k5054 7-Jul-22 17:16pm     CRLF
Why no YouTube? Jason Turner's C++ weekly column did a short intro to C++ regex some time ago. Its only 8:30 minutes long, so a quick watch, and quite clear and understandable. It does assume that you know a little bit of regex's already, so if you're struggling with how to build a regex, it won't be too helpful. If you're just trying to figure out the match portion, this might be enough to get you going. https://www.youtube.com/watch?v=IOxKjqC1Ozo&list=PLs3KjaCtOwSZ2tbuV1hx8Xz-rFZTan2J1&index=65 If you're learning C++, some of his columns might help clear up some of the mysteries.
Dave Kreskowiak 7-Jul-22 18:52pm     CRLF
Because most YouTubers have no idea how to code let alone teach anything.

The tutorial page seems to fit.

std regex C++11 Standard Library Regular Expressions
https://www.regular-expressions.info/stdregex.html

and

std Regular expressions library (C++11)
https://en.cppreference.com/w/cpp/regex
 
Share this answer
 
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx: Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
This site also show the Regex in a nice graph but can't test what match the RegEx: Regexper[^]
 
Share this answer
 
QString testString = "([0-F]{2}[:]){5}[0-F]{2}";


My error was - what is a definition of "preceding element " ?

( )
<pre>([0-F]{2}[:])

here

or [] ?

[0-F]{2}


here ?


SOLVED
 
Share this answer
 
Comments
Peter_in_2780 8-Jul-22 19:00pm    
And it's still wrong. Try ::::::::::::::::: as just one example.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900