Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


Jaden856

4 posts

Wannabe Geek


#302285 12-Nov-2022 22:29
Send private message

Hi

 

 

I'be been following some linux basics and am stuck with 4 exercises around expressions

 

 

 

1.Match this string at the end of a line: EOF$

 

solution ******

 

I tried

 

$EOF\$

 

$EOF\W

 

 

 

2. Match all lines that start with $, followed by any single digit,

 

followed by $, followed by one or more non-whitespace characters

 

 

solution *********

 

I tried $\$\d\s+

 

 

3. Match all of these emails while also adding the username and the domain name (not the TLD) in separate groups (use \w): hello@tryhackme.com, username@domain.com, dummy_email@xyz.com

 

solution ************.***

 

I tried \w{4-11}@\w+.com

 

 

4. match every possible IPv4 IP address (use metacharacters and groups)

 

solution ***{*,*}*.*{*}**{*,*}

 

 

Thanks for any tips :)

Create new topic
fe31nz
1228 posts

Uber Geek


  #2995231 12-Nov-2022 23:42
Send private message

There are many different types of regular expressions.  So the first thing is to know what program is being used and what type of regular expressions it uses.  Is it POSIX basic, POSIX extended, Perl, PCRE, Brief, Slickedit, ....  The most common type is POSIX basic, which is what most decent versions of grep use.  If you use the -E option in grep, then you are likely using POSIX extended.  Perl itself and quite a number of other programs use Perl regular expressions.  For example, Python uses a variant of Perl regular expressions in its "re" module.




surfisup1000
5288 posts

Uber Geek


  #2995235 12-Nov-2022 23:59
Send private message

first one....

 

EOF\$$

 

2nd one. 

 

^\$\d\$\S+

 

 


yitz
2074 posts

Uber Geek


  #2995343 13-Nov-2022 03:28
Send private message

\ a backslash escapes literals like an actual dollar sign character

 

^ caret for matching beginning of line

 

$ dollar for matching end of line

 

square brackets denote groups e.g. [a-z] means all lowercase letters of alphabet [0-9] means all digits 0-9 or a combination [a-zA-Z0-9] or use metacharacters  [\w] all word metacharacters [\d] all digits

 

+ matching one or more occurrences of previous character
* matching zero of more occurrences of previous character
curly braces specify the number of matches (or a range) of the previous character/group of characters

 

Hope this helps without giving away too much...




shaned
20 posts

Geek


  #2995967 14-Nov-2022 12:54
Send private message

Your attempted answers are a little puzzling. I think there may be some fundamental misunderstanding. Perhaps rather than us simply providing solutions, would you mind trying to explain your reasoning behind your answers? I suspect you've absorbed some bad info, and if we can see where you're going wrong, we may be able to get you back on the right track quickly.

Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.