Thread: Regex question
View Single Post
Old 09-30-2022, 10:21 AM   #3
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 786
Karma: 1538394
Join Date: Sep 2013
Device: Kobo Sage
Quote:
Originally Posted by skil-phil View Post
Hi,
I posted a thread a while ago and cannot find it
If this a duplicate I apologize.

I have been getting started with regex expressions using a tutorial I found on these forums.
Finding number sequences work fine.
Number and alpha give me a problem.
Trying to get a match for:
<body class="content" id="uiW9njI8qPGOt6Hp7wdrNu5">
with variable alpha and numerics.
Tried
<body class="content" id="[a-z][A-Z][0-9]">
<body class="content" id="[a-zA-Z0-9]">
<body class="content" id="\w">
None of witch found a match.
What am I missing?
Thanks
Phil
Since you're working through a tutorial, this might not be what you're looking for. But, my search for <body> tags with stuff in them is simply:
Code:
<body.+?>
If I were to look for something of the form you specified, then I'd try:
Code:
<body class=.+? id=.+?>
or, since the class seems fixed:
Code:
<body class="content" id=.+?>
EDIT: From:
https://regex101.com/
Quote:
. matches any character (except for line terminators)
+? matches the previous token between one and unlimited times, as few times as possible, expanding as needed (lazy)

Last edited by enuddleyarbl; 09-30-2022 at 10:37 AM.
enuddleyarbl is offline   Reply With Quote