Question On Regular Expressions In Java - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Question On Regular Expressions In Java (1230 Views)
| Question On Regular Expressions In Java by clockwisereport(op): 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(op): 1:30am On Apr 20, 2019 |
asalimpo:Java how to program by deitel and deitel 10th edition. Thank you |
| Re: Question On Regular Expressions In Java by asalimpo(m): 7:39pm On Apr 20, 2019 |
clockwisereport: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(op): 6:17pm On Apr 21, 2019 |
Thanks @Asalimpo and @Olafisoyem.. I appreciate your efforts |
Need Help In Java • How To Sort Array In Java With User Defined Method ? • Network Programming In Java (UDP And TCP) • 2 • 3 • 4
Php Header() Function Error • I Want To Get Involved In Computer Programming, Where Do I Start? • Sap In Nigeria