Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,084 members, 7,818,246 topics. Date: Sunday, 05 May 2024 at 11:10 AM

Help Me Solve This Java Regex Problem - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help Me Solve This Java Regex Problem (1082 Views)

Please Help Me Solve This MATLAB Problems / Regex Phone Number(nigerian Format) In Python / Help Me Solve This AJAX Problem. (2) (3) (4)

(1) (Reply)

Help Me Solve This Java Regex Problem by DavidTheGeek: 8:39pm On Apr 14, 2017
So i have a string...

example:

String string = "<p>This is a string</p> yes it is but <p>you already know</p> hahaha";

I want to replace the first <p> </p> in this case <p>This is a string</p>.

Note: I don't know the exact word(s) that could be inside the <p> </p>

So here's the regex i wrote..

String newstring = string.replaceFirst("(<p>wink (.+) (</p>wink", ""wink;

It's not working.

It replaces <p>This is a string</p> yes it is but <p>you already know</p> instead of only <p>This is a string</p>.

Anyone, please solve this for me.

** Please click quote to view my regex well.. Silly smiley **
Re: Help Me Solve This Java Regex Problem by asalimpo(m): 1:06am On Apr 15, 2017
I see you took your name inspiration from one DanielTheGeek here.
Try rolling up your sleeves and writing your own solution instead of depending on regex. String manipulation practice is one of the best ways to cut your teeth in programming.
Re: Help Me Solve This Java Regex Problem by DavidTheGeek: 2:13am On Apr 15, 2017
asalimpo:
I see you took your name inspiration from one DanielTheGeek here.
Try rolling up your sleeves and writing your own solution instead of depending on regex. String manipulation practice is one of the best ways to cut your teeth in programming.
grin No i didn't, it's just a coincidence. Funny thing is, before the time i registered the profile, i wasn't really into the Programming section, i was more on the Webmaster section, so i didn't know there was someone called DanielTheGeek. Twas later i came across his profile and i even thought he was the one who mirrored my name, not until i saw his profile was registered before mine.

On the regex issue, i've found a way to manipulate the string to serve my purpose. Though i still hope to see someone else's solution.

(1) (Reply)

Control It All With HC-05/HC-06 Bluetooth Module / ASP.NET Core 1&2 Tutorials / Help On To Score Questionnaire

(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. 9
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.