- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Match any string containing at most one p.
To match any string containing zero or one p’s with JavaScript RegExp, use the p? Quantifier.
Example
You can try to run the following code to match any string containing zero or one p. Here p is considered a number of occurrences −
<html> <head> <title>JavaScript Regular Expression</title> </head> <body> <script> var myStr = "Welcome 1, 100, 10000, 10000"; var reg = /10?/g; var match = myStr.match(reg); document.write(match); </script> </body> </html>
- Related Articles
- Match any string containing one or more p's with JavaScript RegExp.
- Match any string containing a sequence of at least two p's.
- Match any string containing zero or more p's.
- Match any string containing a sequence of N p's
- Match any string containing a sequence of two to three p's.
- Match any string with p at the end of it.
- Match any string with p at the beginning of it.
- How to match any one lowercase vowel in python using Regular Expression?
- How to match any one uppercase character in python using Regular Expression?
- Forming palindrome using at most one deletion in JavaScript
- Get at least one match in list querying with MongoDB?
- Select rows containing a string in a specific column with MATCH and AGAINST in MySQL
- Program to check if binary string has at most one segment of ones or not using Python
- Maximum sum subarray removing at most one element in C++
- Program to find the indexes where the substrings of a string match with another string fully or differ at one position in python

Advertisements