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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:01:33+00:00 2026-06-02T01:01:33+00:00

This if condition: if (preg_match(‘/^[a-zA-Z_]+\z/’, $network_path)) Skips strings like: bla-bla-bla-bla How can I Improve

  • 0

This if condition:

if (preg_match('/^[a-zA-Z_]+\z/', $network_path)) 

Skips strings like:
bla-bla-bla-bla

How can I Improve this regex so it would accept strings like above.. ?

  • 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-02T01:01:34+00:00Added an answer on June 2, 2026 at 1:01 am

    This [a-zA-Z_] is a character class. This construct matches one character from those defined inside the square brackets.

    So this class matches a to z, A to Z and the underscore. If you want to match also a dash, you just need to add it to the class. But be careful, - is a special character inside a character class, so if you want to match it literally you need to escape it or put it to the start or the end of the class.

    if (preg_match('/^[-a-zA-Z_]+\z/', $network_path))
    

    or

    if (preg_match('/^[a-zA-Z_-]+\z/', $network_path))
    

    or

    if (preg_match('/^[a-zA-Z\-_]+\z/', $network_path))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How i can make this condition en VB.NET If e.KeyCode = [a-zA-Z0-9] Then 'Blah
If yes then presentational elements would be helpful in this condition so should we
Is there a way to get single regex to satisfy this condition?? I am
I use this preg_match condition for matching positive, negative and decimal values /^[0-9,-\.]{1,50}$/ But
I have an SP with some condition like this IF NOT EXISTS (Select *
can I code this condition in ruby somehow? I need to know if a
I have a .rhtml file and there are many condition checks like this <%
I have this condition: If (cmbStatusSearch.SelectedValue <> -1) Then How can I make it
I am using this condition as part of my where clause: exists (select *
I use this condition to check if the value is alphanumeric values: $value =~

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.