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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:41:08+00:00 2026-06-15T23:41:08+00:00

Hi need help in using regexp for condition matching. ex.my file has the following

  • 0

Hi need help in using regexp for condition matching.

ex.my file has the following content
{hello.program=’function’`;
bye.program=’script’; }

I am trying to use regexp to match the string that has .program='function' in them:

pattern = '[.program]+\=(function)'

also tried pattern='[^\n]*(.hello=function)[^\n]*';

pattern_match = regexp(myfilename,pattern , 'match')

but this returns me pattern_match={} while i expect the result to be hello.program=’function’`;

  • 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-15T23:41:09+00:00Added an answer on June 15, 2026 at 11:41 pm

    If 'function' comes with string-markers, you need to include these in the match. Also, you need to escape the dot (otherwise, it’s considered “any character”). [.program]+ looks for one or several letters contained in the square brackets – but you can just look for program instead. Also, you don’t need to escape the =-sign (which is probably what messed up the match).

    cst = {'hello.program=''function''';'bye.program=''script'''; };
    pat = 'hello\.program=''function''';
    out = regexp(cst,pat,'match');
    out{1}{1} %# first string from list, first match
       hello.program='function'
    

    EDIT

    In response to the comment

    my file contains

    m2 = S.Parameter;
    m2.Value = matlabstandard;
    m2.Volatility = ‘Tunable’;
    m2.Configurability = ‘None’;
    m2.ReferenceInterfaceFile =”;
    m2.DataType = ‘auto’;

    my objective is to find all the lines that match, .DataType=’auto’

    Here’s how you find the matching lines with regexp

    %# read the file with textscan into a variable txt
    fid = fopen('myFile.m');
    txt = textscan(fid,'%s');
    fclose(fid);
    txt = txt{1};
    
    %# find the match. Allow spaces and equal signs between DataType and 'auto'
    match = regexp(txt,'\.DataType[ =]+''auto''','match')
    
    %# match is not empty only if a match was found. Identify the non-empty match
    matchedLine = find(~cellfun(@isempty,match));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help with using VQmod, if anyone has any experience with, I'd appreciate
Need help writing a script downloads data from google insight using c# this is
I need help in jquery. Thanks in advance. I am using autocomplete function of
I need a help with this regexp.. using /\{block:(Posts|Photos|Videos)(\s\[.*?\])?\}(\s?[^\]+\s?)\{\/block\}/U i get {block:Posts}abcdef{/block} from this:
I'm using Sybase 12.5.3, and want/need to do regex pattern matching. The Sybase help
Need help using regex and powershell to accomplish the following. I have the following
I need some help using regex in java. Im trying to achieve 2 different
Possible Duplicate: Regular expression: match all words except I need your help for using
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
We are using Linq-to-SQL with stored Procedures we need help on one of our

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.