JavaScript RegExp \0 Metacharacter

The regex "\0" shows the available null character in the input string in JavaScript. If the null value is available, then the position of the values shows; otherwise, the "-1" value shows using the search method. We can test, search, and match the required string using this Metacharacter.

Syntax

The syntax is used to show available characters at the string's start.

or

Supported Browsers:

The RegExp \0 Metacharacter supports the following browsers supported using the JavaScript function:

  • Google Chrome
  • Apple Safari
  • Mozilla Firefox
  • Opera
  • Internet Explorer

Examples

The following examples are used to search, match, test, and execute null values using javascript's "\0" regex metacharacter.

Example 1

The following example shows a test null character metacharacter of the regex in JavaScript. The test method shows true or false if the value is available.

Output

The output shows the non-word character of the string.

JavaScript RegExp \0 Metacharacter

Example 2

The following example shows the position of the null character metacharacter of the regex in JavaScript. If the null value is unavailable, then "-1" shows as an output.

Output

The output shows the position of the null character of the string.

JavaScript RegExp \0 Metacharacter

Example 3

The following example shows the position of the null character metacharacter of the regex in JavaScript. If the null value is unavailable, "null" is an output.

Output

The output shows the position of the null character of the string.

JavaScript RegExp \0 Metacharacter

Example 4

The following example shows the replacement value with the null character metacharacter using the regex in JavaScript. We can replace it with the "88" value to replace the null metacharacter "/0".

Output

The output shows the replaced value with the available null characters of the string.

JavaScript RegExp \0 Metacharacter

Conclusion

The regular expression helps to find null characters in the information using JavaScript methods. The simple Metacharacter helps to validate user-interactive data.






Latest Courses