Regular Expression related: first character alphabet second onwards alphanumeric+some special characters

I have one question related with regular expression. In my case, I have to make sure that first letter is alphabet, second onwards it can be any alphanumeric + some special characters. Regards, Anto

Filter array of numeric PIN code strings which may be in the format "######" or "### ###"

I have a PHP array of strings. The strings are supposed to represent PIN codes which are of 6 digits like: 560095 Having a space after the first 3 digits is also considered valid e.g. 560...

How to validate numeric values which may contain dots or commas?

I need a regular expression for validation two or one numbers then , or . and again two or one numbers. So, these are valid inputs: 11,11 11.11 1.1 1,1

What are the differences between PEGs and CFGs?

From this wikipedia page: The fundamental difference between context-free grammars and parsing expression grammars is that the PEG's choice operator is ordered. If the first alternative succeeds,...

Regular expression help - comma delimited string

I don't write many regular expressions so I'm going to need some help on the one. I need a regular expression that can validate that a string is an alphanumeric comma delimited...

Remove all non-numeric characters from a string; [^0-9] doesn't match as expected

I'm trying to remove everything from a string but just numbers (0-9). I thought this would work.. echo preg_replace("[^0-9]","",'604-619-5135'); But it echos "604-619-5135". What am I missing???

Case-insensitive search and replace

I have the following string, how do I search and replace it in Java? Before *animal is a *ANImal and *Bird is a *bIrd. After search and replace, it shoud be *animal = Dog and *bird = Peacock Dog...

Function to check if a string is a date

I am trying to write a function to determine if a string is a date/time using PHP. Basically a valid date/time would look like: 2012-06-14 01:46:28 Obviously though its completely dynamic any...

Get a specific substring from a text string after comma or point characters in Notepad++

I need help with NOTEPAD++ regular expressions. This seems kind of simple ... uff. I have a xls file with 4 columns that contain text strings (1 column = 1 language). When I copy one line from...

Regular expression to match a backslash followed by a quote

How to write a regular expression to match this \" (a backslash then a quote)? Assume I have a string like this: <a href=\"google.com\"> click to search </a> I need to replace all the \" with a...

Regex for allowing alphanumeric,-,_ and space

I am searching for a regular expression for allowing alphanumeric characters, -, _ or spaces in JavaScript/jQuery. I tried Googling but wasn't able to find that. Can anyone help me out with...

Matching the same word twice with a regular expression, not caring what the word is

Take the following input: foo.foo aefhiuafhiauefheiauh bar.bar jgoeiajgoieajogiae baz.foo ogiejaogijaeoigjea Say I want to match x.x where x is the same both sides of the dot. So I don't want to...

How do I combine COUNTIF with OR

In Google Spreadsheets, I need to use the COUNTIF function on a range with multiple criteria. So in the table below, I would need to have something like =COUNTIF(B:B,"Mammal"or"Bird") and return...

How to extract slug from URL with regular expression in Python?

I'm struggling with Python's re. I don't know how to solve the following problem in a clean way. I want to extract a part of an URL, What I tried so far: url =...

How do I print out just the word itself in a WordNet synset using Python NLTK?

Is there a way in Python 2.7 using NLTK to just get the word and not the extra formatting that includes "synset" and the parentheses and the "n.01" etc? For instance if I do ...

put dash after every n character during input from keyboard

$('.creditCardText').keyup(function() { var foo = $(this).val().split("-").join(""); // remove hyphens if (foo.length > 0) { foo = foo.match(new RegExp('.{1,4}', 'g')).join("-"); } ...

Regex to reject characters ;*&%^=""

I need to validate an input field using regex but the input field should not be present for these characters ;*&%^="". Regex which I wrote \A.+[a-z0-9A-Z]+\Z, did not validate. Any help would be...

Validate Bangladeshi phone number with optional +88 or 01 preceeding 11 digits

I am using the following regular expression to validate an Indian phone number. I want optional +88 or 01 before 11 digits of phone. Here is what I am using: string mobileNumber =...

What is a reliable isnumeric() function for python 3?

I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or...

preg_match accented characters

I have an issue using preg_match with php. I want my users to fill the Name field with only valid characters. Ex: no numbers or special chars. My site will eventually be bilingual but most of my...

Filter array elements by searching for partial match in keys and values

is it possible to do searching in PHP array same we do in MySQL. Eg: I have this array array( '[email protected]'=> `Mark Mian`, '[email protected]'=> `John jack`, '[email protected]'=> `Bob Logon`, ...

Remove Hebrew vowels (nikkud) from selected Unicode Hebrew text

I want to select a string of Unicode Hebrew text in a Word document and remove the Hebrew vowels (aka nikkud) without changing anything else. I need to remove Unicode characters in a given range...

Issues with extracting substrings of a string in Python Pandas Dataframe

I have an expression like ( one row of a column, say 'old_col' in pandas data frame) ( Shown the top two rows from a column of the dataframe ) abcd_6.9_uuu ghaha_12.8 _sksks abcd_5.2_uuu...

Filter array to keep values containing the search word using word boundaries

I know this type of question has been asked before and I also saw those working answers. However, it's not working when there are no space between the search string and the rest of the array...

Replace whole words from blacklist array instead of partial matches

I have an array of words $banned_names = array('about','access','account'); The actual array is very long a contains bad words so at risk of breaking any rule I just added an example, the issue...

How to make proper Input validation with regex?

I want let users enter only integer or floating numbers. Right now I can only enter integer numbers,it does allow type dot or comma . Cant find proper regex to validate both integer and floating...

Regex to capture html elements with their class name

I am trying to get the element and class name for all elements within an html file using python. I managed to get all class names with the code below. It's written like that because I will go...

How to rewrite URLs from UPPERCASE to lowercase in .htaccess

I'm trying to assemble a regular expression to rewrite a URL containing uppercase characters to the same URL but in all lowercase. Example: example.com/foO-BAR-bAz rewrite to...

How to remove a character from some rows in a dataframe column?

I have a large dataframe that I need to clean, as a sample please look at this dataframe import pandas as pd cars = {'Brand': ['Honda Civic','Toyota Corolla','Ford Focus','Audi A4','Suzuki'], ...

How in Jest testing to match a string which contains a "/" and gives a syntax error

In my React application, I'm writing a Jest testing to test if on screen I get a specific date, time, and timezone. The test looks as it is test('Local date time format - Europe no UK', () => { ...