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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:40:56+00:00 2026-05-27T01:40:56+00:00

Suppose I have string variables like following: s1=10$ s2=10$ I am a student s3=10$Good

  • 0

Suppose I have string variables like following:

s1="10$" 
s2="10$ I am a student"
s3="10$Good"
s4="10$       Nice weekend!"

As you see above, s2 and s4 have white space(s) after 10$ .

Generally, I would like to have a way to check if a string start with 10$ and have white-space(s) after 10$ . For example, The rule should find s2 and s4 in my above case. how to define such rule to check if a string start with ’10$’ and have white space(s) after?

What I mean is something like s2.RULE? should return true or false to tell if it is the matched string.

———- update ——————-

please also tell the solution if 10# is used instead of 10$

  • 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-27T01:40:57+00:00Added an answer on May 27, 2026 at 1:40 am

    You can do this using Regular Expressions (Ruby has Perl-style regular expressions, to be exact).

    # For ease of demonstration, I've moved your strings into an array
    strings = [
      "10$",
      "10$ I am a student",
      "10$Good",
      "10$       Nice weekend!"
    ]
    
    p strings.find_all { |s| s =~ /\A10\$[ \t]+/ }
    

    The regular expression breaks down like this:

    • The / at the beginning and the end tell Ruby that everything in between is part of the regular expression
    • \A matches the beginning of a string
    • The 10 is matched verbatim
    • \$ means to match a $ verbatim. We need to escape it since $ has a special meaning in regular expressions.
    • [ \t]+ means “match at least one blank and/or tab”

    So this regular expressions says “Match every string that starts with 10$ followed by at least one blank or tab character”. Using the =~ you can test strings in Ruby against this expression. =~ will return a non-nil value, which evaluates to true if used in a conditional like if.

    Edit: Updated white space matching as per Asmageddon’s suggestion.

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

Sidebar

Related Questions

I am confused between NSString and NSMutable string usage. Suppose I have instance variables
Suppose I have a string like this: one two three four five six seven
Suppose, I have the following code class C { int i; String s; C(){
Suppose if I have an Annotation like the following [DisplayFormat(DataFormatString = {0:#.00#}, ApplyFormatInEditMode =
I need some advice. Suppose I have the following string: Read Variable I want
Suppose I have a class structure like the following, where I have a temporary
Suppose I have the following classes: public class Test { public static void main(String[]
Suppose I have string Name and Image Photo as properties of a class in
Suppose I have a string 'johndoe@hotmail.com' . I want to store the string before
Suppose I have a string that contains Ü. How would I find all those

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.