- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
How to skip character in capture group in JavaScript Regexp?
You cannot skip a character in a capture group. A match is always consecutive, even when it contains things like zero-width assertions.
Example
However, you can access the matched groups in a regular expression like the following code −
<html> <head> <script> var str = "Username akdg_amit"; var myReg = /(?:^|\s)akdg_(.*?)(?:\s|$)/g; var res = myReg.exec(str); document.write(res[1]); </script> </head> <body> </body> </html>
Advertisements