Hello! I'm having some issues implementing the appropriate regex patter to eliminate unwanted characters from a string.
Here is a sample string:
Code: String str = "test-hello. me please3, _dog[ -()"; What I need to do is create a regex that will take out all non word characters except for spaces AND strings of type "test-hello" - in other words any string that has word or digit characters followed by a "-" (hyphen) followed by more word or digit characters - this is what is giving me trouble.
What I have right now which is perfect except for the "test-hello" type strings is:
Code: Pattern replace = Pattern.compile("([^\w ])");Matcher matcher = replace.matcher(str);str = matcher.replaceAll(""); The above code removes all non word or digit characters except for spaces but it will obviously still remove the "-" in "test-hello".
I'm not looking for the whole answer of course but any tips or resources I can be pointed to would be greatly appreciated. I'm not familiar with the regex syntax in Java as I am in say PHP.
Thank you!
problems with php variables in mysql query
i can't seem to get the following query to work. select $q1c from $vote_rate where id = $recent_record LIMIT 0,1 ;this method did not work eitherselect .$q1c. from .$vote_rare. where id =
Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to retrieving and displaying data, but if I click on a valid link in the following code, the content and
problem with php mysql query
Hi guy's...I'm totally lost here..because don't have any idea how to make a query for grab record using BETWEEN startdate and enddate since existing record are stored using this format
problem with query error
First Thanks to those who helped me on my previous posts, and the following code i'm using is not mine, i grabbed it from here http://www.phpfreaks.com/tutorial/basic-paginationNow onto the
getting a website's source code as a variable? How?
Hey guys, is there any way for me to get the source code of a website as a variable for me to work with?Ex:$url="http://www.google.com"$sourcecode=magicfunction($url);//so that i could
Displaying image from database
Hi,I've got a site where that's got a database behind it. Currently it has loads of items in rows that all have different pictures. There is a field called "Image" that has the name of the
array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I have a .csv file with about 300 records in it. The code worked perfect while testing on 3 or 4
If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.i have this code Code: echo '<form action="archivedBookings.php" method="get">';
need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user select any value in that menu and press submit then it does not pass to next page.my code is
Save username into DB
OkaY so I got my blog to actually save the posts and whatever, all I need now is for it to keep the right posted. That database is set up to keep post id, title, subject, date, and author. The only