Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:19:47+00:00 2026-06-17T10:19:47+00:00

Not sure why but the behaviour is strange. Whenever I use the \u0000 in

  • 0

Not sure why but the behaviour is strange. Whenever I use the \u0000 in the regular expression, it then matches nothing.

var regexpNotWorking:RegExp = new RegExp("[^\u0000-\u0020]");
var regexpWorking:RegExp = new RegExp("[^\u0001-\u0020]");
var input:String = "I should be valid";
trace("not working: " + input.match(regexpNotWorking));
trace("working: " + input.match(regexpWorking));

the output are:

not working: null
working: I

Anyone has idea why \u0001 is working, but \u0000 is not?

How could I make sure the input does not contain \u0000?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:19:48+00:00Added an answer on June 17, 2026 at 10:19 am

    Why not remove the negation and change the regular expression to this:

    var regexp:RegExp = /[\u0021-\uFFFF]/;
    

    BTW no need to use new RegExp or quotes around regular expressions in Flex.

    But that’s probably not quite the answer you are looking for. Here’s one way to find if a string contains a NUL character.

    public function stringHasNul(value:String):Boolean {
        return (value.length != value.replace("\u0000", "NUL").length);
    }
    
    var hasNul:String = "ABC\u0000DEF"
    var noNuls:String = "ABCDEF";
    
    trace(hasNul.length); // should be 7
    trace(hasNul.search("\u0000")); // wrongly gives 0, should be 3
    trace(noNuls.length); // should be 6
    trace(noNuls.search("\u0000"));  // wrongly gives 0, should be -1
    
    trace(stringHasNul(hasNul)); // displays true
    trace(stringHasNul(noNuls)); // display false
    

    To check if any characters are in the range \u0000 to \u0020 you can do this:

    var regexp:RegExp = /[^\u0021-\uFFFF]/;
    
    if (somestring.search(regexp) == -1)
    {
        // somestring is valid do something with it
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python is exhibiting a strange behaviour that I didnt witness before, not sure what
I have a strange behavior when parsing a large xml (but I'm not sure
Not sure if someone has already asked this, but I see a strange behavior
I am using D-Day calendar and I am not sure but I got a
I am not sure why but jQuery find function is not able to find
I'm not totally sure but this looks wrong: I have a header file named
I know what i want but not sure of the name and required tools
I'm starting out with MVC but not sure it's the best option. I need
I am fairly new to MVC but not sure exactly which Redirect... replaces the
I'm not sure that title is worded very well, but not sure how else

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.