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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:51:08+00:00 2026-06-14T00:51:08+00:00

I am trying to parse a string with something like : preg_match( |from:(.*?);|, $string,

  • 0

I am trying to parse a string with something like :

preg_match( "|from:(.*?);|", $string, $match);

But then I found that the string can also contain lfrom: and _from:

A few examples of how the string can be:

var1:34234;from:website1.com;lfrom:website2.com;var2:343423;
lfrom:website1.com;var1:4234234;from:website2.com
from:website1.com;_from:website2.com;lfrom:website2.com;var1:43523;

How can I parse only from:(.*?); and not lfrom, _from, etc.

  • 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-14T00:51:11+00:00Added an answer on June 14, 2026 at 12:51 am

    I was gonna give you the solution but I better explain you about the lookbehind modifier.

    In regex each time you “match” a h for example, that h will add 1 to the pointer of where the regex is at the moment so you dont want to “add” nothing to the pointer. You just want to look if the from is preceded by a ;\s\b or the start of the string. You don’t want to match the VOID because there are voids everywhere!!

    So, an example: (?<a)b that would match a b that has an a before it. So it just does the next: When a b found it looks before it, if there is an a it matches the regex.

    So… (?<=[;\s\b]|^)from:(\w+\.\w+) Would match a from that right before it has [;\s\b] OR ^ (The string start)

    DEMO

    Pretty easy, huh!?

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

Sidebar

Related Questions

I'm trying to convert a date string from another application in Groovy. Something like
I am trying to parse a string something like this: Input 20:00 - output
I'm trying to parse strings that represent source code, something like this: [code lang=html]
I'm trying to parse a string that was generated by an NSDateFormatter using another
I'm trying to parse the string below in a good way so I can
I am trying to parse an SQL date string (ISO 9075) and that uses
I'm trying to parse string representation of date. It looks like 20120306 14:21:35 MSK
i'm trying to get web-page data in string that than i could parse it.
I have a string that looks something like this: {{imagename.jpg|left|The caption for this image.
I'm trying to parse google atom with XmlSlurper. My use case is something like

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.