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

  • Home
  • SEARCH
  • 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 7072975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:52:25+00:00 2026-05-28T05:52:25+00:00

I have some regular expressions in my database which are then instantiated in Ruby

  • 0

I have some regular expressions in my database which are then instantiated in Ruby with something like:

rx = Regexp.new(rx_string)

I want to validate the regular expression from right within the form that submits it to my Rails server using JavaScript, to display a red border, so that when submitted and used later on, it will not raise an exception in Ruby.

Is there an easy way of giving Ruby’s regular expression engine’s definition to a JavaScript script that will come up with a true or false on whether the regex is valid in Ruby?

  • 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-28T05:52:26+00:00Added an answer on May 28, 2026 at 5:52 am

    The differences between Ruby’s regex syntax and JavaScript’s can be found here: Differences between Ruby 1.9 and Javascript regexp

    I suggest taking the input string, removing all Ruby features (e.g. (?#comments...)) and testing whether it’s a valid regex in JavaScript:

    try {
      RegExp(input); valid = true;
    } catch(e) {
      valid = false;
    }
    

    Removing all Ruby features from the input string will be the tricky bit.

    I can’t think of an easier way without have some super-long ruby-regex-validating-regexp to hand.

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

Sidebar

Related Questions

im new to regular expressions in php. I have some data in which some
I have some complex regular expressions which I need to comment for readability and
I have some unicode text that I want to clean up using regular expressions.
I have some difficulties in understanding if-then-else conditionals in regular expressions. After reading If-Then-Else
Hi have some forms that I want to use some basic php validation (regular
I have some useful regular expressions in Perl. Is there a simple way to
I have some php code that contains regular expressions and I was wondering what
Does anyone have some good resources on learning more advanced regular expressions I keep
I have a database filled with some codes like EE789323 990 78000 These numbers
I have inherited some code that uses regular expressions to parse CSV formatted data.

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.