How-to articles, tricks, and solutions about REGEX

Allow only [a-z][A-Z][0-9] in string using PHP

You can use the preg_replace function in PHP to remove any characters that do not match the specified pattern.

Check and extract a number from a String in Java

To check if a string contains a number and extract the number from the string in Java, you can use a combination of the matches method of the String class and the find method of the Matcher class.

Convert plain text URLs into HTML hyperlinks in PHP

You can use the preg_replace() function in PHP to convert plain text URLs into HTML hyperlinks.

Function to return only alpha-numeric characters from string?

To return only alpha-numeric characters from a string in PHP, you can use the preg_replace function with a regular expression pattern that matches any non-alphanumeric character.

How to add http:// if it doesn't exist in the URL

You can use the following code snippet to add "http://" to the beginning of a URL if it doesn't already exist:

How to Check If a String Contains Another Substring in JavaScript

Read this tutorial and learn several methods used to check if a string contains another substring in JavaScript or not. Read information and see examples.

How to Check Whether a String Matches a RegEx in JavaScript

Read and learn two methods used to check whether a string matches RegEx in JavaScript. Also, see which method is the fastest and differences between them.

How to Compare Strings in Java

The comparison of strings is one of the mostly used Java operations. If you’re looking for different ways to compare two strings in Java, you’re at the right place.

How to Count String Occurrence in String

Read this tutorial and learn several useful methods that are used to count the string occurrence in a string. Choose one of the working methods for you.

How to extract a substring using regex

To extract a substring from a string using a regular expression in Java, you can use the following steps:

How to extract numbers from a string in Python?

In Python, you can use regular expressions to extract numbers from a string.

How to HTML-encode a String

Read this JavaScript tutorial and learn about some useful and fast methods that help you to HTML-encode the string without causing the XSS vulnerability.

How to match "any character" in regular expression?

To match "any character" in a regular expression, you can use the . (dot) character. The . character matches any single character, except for a newline.

How to match whitespace, carriage return and line feed using regular expression in PHP?

In PHP, you can match whitespace, carriage return, and line feed using the following regular expression:

How to Remove Spaces From String

Read this JavaScript tutorial and learn several methods that are used to remove spaces from a string. Also, know which is the fastest method to choose.

How to Remove Text from String

Read this JavaScript tutorial and learn useful information about several easy and fast built-in methods that are used for removing the text from a string.

How to Split a String in Java

Learn the ways to split a string in Java. The most common way is using the String.split () method, also see how to use StringTokenizer and Pattern.compile ().

How to Validate an E-mail Using JavaScript

Read this tutorial and learn a fast and easy solution to the issue of validating an email using JavaScript. Also, you will read about what the email is.

How to Validate an Email with PHP

This tutorial explains how to validate an email using the PHP arsenal. Check out the examples of how to do that with the help of a PHP function and regex.

How to Validate URL with PHP

In this snippet, we provide guidelines on one of the most common issues in PHP. Here, we show the most straightforward way on how to validate URL with PHP.

Java string split with "." (dot)

To split a string in Java using a dot (.) as the delimiter, you can use the split method of the String class.

Java; String replace (school project)?

To replace a substring in a string in Java, you can use the replace() method of the String class.

PHP Regex to get youtube video ID?

You can use the following regular expression to extract the YouTube video ID from a URL:

PHP string "contains"

To check if a string contains another string in PHP, you can use the strpos() function.

PHP/regex: How to get the string value of HTML tag?

In PHP, you can use the preg_match() function to extract the string value of an HTML tag.

1 2