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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:00:29+00:00 2026-05-23T11:00:29+00:00

I searched but have not found an answer to the question – maybe it

  • 0

I searched but have not found an answer to the question – maybe it is so obvious that no one else had to ask…

I am using UltraEdit 16.00 to run my Regular Expressions in PERL mode…

Situation:

I have a delimited string that can contain a variable number of repeating segments that must adhere to a very specific format. These segments occur randomly throughout the delimited string.

Example:

CLP*data*data*data~REF*data*data~N1*data*data*data~**CAS*OA*29*99.99**~AMT*I*99.99~SVC*data*data*data*data~**CAS*PR*99.99**~**CAS*CO**99.99**~DTM*150*date~AMT*B6*99.99~SVC*data*data*data*data~CAS*PR*N16*99.99~**CAS*CO* *99.99**...line continues from here.

Correct format – CAS*OA*29*99.99~
Incorrect format 1 – CAS*OA* *99.99~
Incorrect format 2 – CAS*OA**99.99~

Goal:

Identify only those strings where ALL of the CAS segments adhere to the format.

Things I’ve Tried:

(BTW: I know my Regular Expressions are not optimized, so please give me a break)

CAS Segment Missing value or containing one or more spaces

CAS\*(OA|PR|CR|CO)\*\*[-]?[\d]+\.?[\d]{0,2}~ matches the first instance if finds
CAS\*(OA|PR|CR|CO)\*[\s]+?\*[-]?[\d]+\.?[\d]{0,2}~ matches the first instance if finds

CAS segment NOT Missing value or containing space(s)

CAS\*(OA|PR|CR|CO)\*[^0-9A-Z]+?\*[-]?[\d]+\.?[\d]{0,2}~ Again, matches first instance

Negative Lookahead using combinations of the above (I am new to trying this approach)

^(?:(?!ab).)+$ – ab => one of the above regular expressions – never got it to work

Question:

How do I write the regular expression to enforce/validate the format of EVERY CAS instance no matter how often it occurs (there is a potential for 0 instances)?

  • 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-23T11:00:29+00:00Added an answer on May 23, 2026 at 11:00 am

    To say that every CAS instance in your string is valid is to say that there does not exist at least one invalid CAS sequence. The approach you were getting at with a negative lookahead is the simplest way to represent this – here’s an example:

    /^(?!.*CAS(?!<whatever matches a valid CAS instance>))/
    

    Basically: “Make sure there does not exist in the string an instance of CAS that is not followed by whatever matches a valid CAS instance”. Replace the contents of the second negative lookahead, and include whatever it is before ‘CAS’ that indicates the start of a CAS instance.

    As you can see, you don’t need to match the string from start to finish to do what you want.

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

Sidebar

Related Questions

Just wondering I have searched but I have not found an answer. My question
I have searched for topics specifically to this question but have not found anything
I have searched this question, and found an answer in MySQL but this is
I've searched for a potential answer to my question below, and have not found
I have searched far and wide on the Internet but have not found anything
I've searched the iPhone documentation and on google but have not found any information
I have searched online for a solution, but have yet to find one that
I have searched internet and stackoverflow thoroughly, but I haven't found answer to my
I've searched around for answers to this question, but not found anything quite on
I am sorry of the question, but i have searched but i have not

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.