RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Javascript Tokenizer
Expression
(\/\*[\s\S.]+?\*\/|[/]{2,}.*|\/((\\\/)|.??)*\/[gim]{0,3}|'((\\\')|.??)*'|"((\\\")|.??)*"|-?\d+\.\d+e?-?e?\d*|-?\.\d+e-?\d+|\w+|[\[\]\(\)\{\}:=;"'\-&!|+,.\/*])
Description
Tokenize a Javascript document for parsing each token is a language-token : string, int, float, comment, multiline comment, operator, expression etc. etc.
Matches
var a = 12.5 * 5 + 3e9;var b = "str'\"ing";var c = 'str"\'ing';var d = /regex/gi;var e = Func();
Non-Matches
spaces/newline/tab
Author Rating: The rating for this expression. Martin Kirk
Source (\/\*[\s\S.]+?\*\/|[/]{2,}.*|\/((\\\/)|.??)*\/[gim]{0,3}|'((\\\')|.??)*'|"((\\\")|.??)*"|-?\d+\.\d+e?-?e?\d*|-?\.\d+e-?\d+|\w+|[\[\]\(\)\{\}:=;"'\-&!|
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Fails on certain identifiers
Name: Takuan
Date: 6/19/2008 12:16:19 PM
Comment:
Fails to recognize '$' as a valid character in a javascript identifier, which can be important because some of the most common js frameworks and libraries (like jQuery) make extensive use of this. You can easily verify this by testing the following text: $(oldElement).appendTo(form);


Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials