Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,839 members, 7,810,226 topics. Date: Saturday, 27 April 2024 at 12:57 AM

Question On Regular Expressions In Java - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Question On Regular Expressions In Java (1093 Views)

How To Sort Array In Java With User Defined Method ? / Network Programming In Java (UDP And TCP) / I Have A Very Import Question On Python Syntax (2) (3) (4)

(1) (Reply) (Go Down)

Question On Regular Expressions In Java by clockwisereport: 1:52pm On Apr 18, 2019
Good day house!
Can someone please explain what regular expressions are in java and how they are being used. Thank you
Re: Question On Regular Expressions In Java by airsaylongcon: 3:02pm On Apr 18, 2019
Following. Regex have always left me in a twist l
Re: Question On Regular Expressions In Java by asalimpo(m): 10:16pm On Apr 19, 2019
Op, what textbook are u using?
Re: Question On Regular Expressions In Java by clockwisereport: 1:30am On Apr 20, 2019
asalimpo:
Op, what textbook are u using?

Java how to program by deitel and deitel 10th edition. Thank you

1 Like

Re: Question On Regular Expressions In Java by asalimpo(m): 7:39pm On Apr 20, 2019
clockwisereport:


Java how to program by deitel and deitel 10th edition. Thank you
Regular expressions are mini languages within programming languages whose domain are strings. So regex is for describing string patterns. It has a syntax (varies according by language). The issue is in learning the syntax. I found it weird when I was starting out, but now it ain't so intimidating, just off-putting . My advice is don't bother with it,if you don't have to. When you are more mature and grounded in programming you give it a try. I wrote/still write all string manipulation functions by hand and have never used regex. Though I write code in d thousands of lines. But if you wanna still grok it,ditch deitel. Their books are glossy but crap. And they don't explain regular expressions well at al. Get a dedicated resource on by regex then study from there. The diffs btw typical regex and typical programming languages are that usually, you can't create variables. You can't do explicit iteration: looping.
If you use Windows command line, you probably use some form of regex. E.g to find all Java files in a directory,you'd enter dir *.java . The * is short for match 0 to inf characters. They are actually 2 bits or components to that pattern . 1)* 2) .java . So the engine that processes regexes will match for the two, component by component. If you weren't using regex but rather using explicit string methods,you'd call endsWith() . Still same thing.
Re: Question On Regular Expressions In Java by Olafisoyem: 10:50am On Apr 21, 2019
It’s used to compare and match strings. It’s like having a circular hole and seeing if a circle will fit or if a square will fit.

For instance in scala/pseudocode I can say:
Val regex = ([0-9]).r
Val number = 6
println(number.matches(regex)) //true
Re: Question On Regular Expressions In Java by clockwisereport: 6:17pm On Apr 21, 2019
Thanks @Asalimpo and @Olafisoyem.. I appreciate your efforts

(1) (Reply)

Meet Silas Adekunle, Highest Paid Robotics Engineer In The World / Which Is Better Btw KOTLIN & FLUTTER / In Need Of A Programming Mentor

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.