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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:26:29+00:00 2026-05-25T02:26:29+00:00

I am in the process of formulating a regex for validating a text area

  • 0

I am in the process of formulating a regex for validating a text area that contains entries of the following format,

an url, boolean(true or false), string(with or without spaces)

An example is as follows,

http://www.yahoo.com, true, web mail site
http://www.google.com, false, a search site

So I was trying to formulate a regex for each line as below,

(^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*$)(,(true|false))(,(.*))

Hence I can check each line, but this regex is not working. The whole regex fails to match the type of comma separated string. Also is there some way I can make this regex check for multiple lines and validating this pattern?

  • 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-25T02:26:30+00:00Added an answer on May 25, 2026 at 2:26 am

    If the line breaks are your only problem, you could use the Pattern.MULTILINE flag:

    Pattern.compile("^((?:https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]), (true|false), (.*)$", Pattern.MULTILINE|Pattern.CASE_INSENSITIVE);
    

    You can also embed the flag(s):

    Pattern.compile("(?mi)^((?:https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]), (true|false), (.*)$",);
    

    I took the liberty of using a different regex for your URL (it’s from Regex Buddy). This also will put everything in a capture group.


    Demo: http://ideone.com/I9vpB

    public static void extract(String str) {
    
        Pattern regex = Pattern.compile("(?mi)^((?:https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$!:,.;]*[A-Z0-9+&@#/%=~_|$]), (true|false), (.*)$");
    
        Matcher m = regex.matcher(str);
        while (m.find()) {
            System.out.println("URL:  " + m.group(1));
            System.out.println("Bool: " + m.group(2));
            System.out.println("Text: " + m.group(3) + "\n");
        }
    }
    
    public static void main (String[] args) throws java.lang.Exception
    {
        String str = "http://www.yahoo.com, true, web mail site\nhttp://www.google.com, false, a search site";
        extract(str);
    }
    

    Outputs:

    URL:  http://www.yahoo.com
    Bool: true
    Text: web mail site
    
    URL:  http://www.google.com
    Bool: false
    Text: a search site
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I process a lot of text/data that I exchange between Python, R, and sometimes
Process process = new Process(); ProcessStartInfo psi = new ProcessStartInfo(@C:/PsExec.exe); psi.UseShellExecute = false; psi.RedirectStandardOutput
There is a conversion process that is needed when migrating Visual Studio 2005 web
foreach (Process newprcs in oPrcs) { newprocid = (UInt32)newprcs.Id; if (!oNewProcs.Contains(newprocid)) //checking process id
I have 1 process that receives incoming connection from port 1000 in 1 linux
Process cExe = new Process(); cExe .StartInfo.FileName = cexe.exe; cExe .EnableRaisingEvents = true; cExe
The process is explained here: http://msdn.microsoft.com/en-US/library/d1ae6tz5%28v=VS.80%29.aspx What I don't get from that article is
Every process running on a machine is given the illusion that it is the
My process reads from a single queue tasks that need to be sent to
process of encoding. its work byte[] key = Form1.StrToByteArray(1234567812345678);//secret key byte[] data = Form1.StrToByteArray(ololoololoololoololoololoololoololoololoololoololoololoololoaaas);//text

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.