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 7219071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:34:42+00:00 2026-05-28T21:34:42+00:00

Hello i have a TextField on my scene. It haves only digits, user input

  • 0

Hello i have a TextField on my scene. It haves only digits, user input them by clicking on buttons (NumPad). I want to separate each five-character by ‘-‘ . User must input 20 digits

I’m using this code

var rexp:RegExp  = new RegExp("/^((\d{0,5})(\d{0,5})(\d{0,5})(\d{0,5}))$/"); 
trace(rexp.test(textEnter.text)); //always false
var s:String=textEnter.text.replace(rexp, "$2-$3-$4-$5"); 
trace(s);//format is fails
textEnter.text = s;

On this site my patterns are working fine. But they aren’t working in my AS3 script.

can you help me and say what i’m doing wrong.

  • 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-05-28T21:34:43+00:00Added an answer on May 28, 2026 at 9:34 pm

    There are two ways to instantiate a regex in AS3. You can either use the constructor form or the regex literal form.

    Literal form

    With this notation, the regex literal creates an implicit regex object, so you don’t have to. The following works fine:

    var rexp:RegExp = /^((\d{0,5})(\d{0,5})(\d{0,5})(\d{0,5}))$/;
    

    Constructor form

    If you really want to use the constructor form to instantiate your regex, then you replace the delimiting forward slashes with quotation marks. You must also add a second backslash to any metasequences.

    var rexp:RegExp  = new RegExp("^((\\d{0,5})(\\d{0,5})(\\d{0,5})(\\d{0,5}))$"); 
    

    More info: http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e92.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HEllo, I have a site where I want to introduce reply user functionality. How
I have a textfield on my app, and a button. I only want that
I have a textfield <input type=text/> that I want to validate when the focus
hello all i have my four textfield for entering password If my password is
Hello I have the followong struggle in my head. I want a text-field in
I want to have a form with an input text field and be able
I want to detecting when a user clicks OUT of an input type Text
I have two textfield, in first textfield I write Hello and when I push
I have a Django model: class Note(models.Model) : text = models.TextField() owner = models.ForeignKey(User)
Hello I have a django app dealing with Sales/purchases. What I want to do

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.