PHP intercepts string problems! Online and other online knot stickers

Source: Internet
Author: User
Tags strtok
Yybb_cx.
Yybb_xdf.

Just like the string above. I just need _ back and. Letters in front

For example, the above two I need is CX and xdf what should be done?


Reply to discussion (solution)

$s =<<
  
  

Is this the replacement of the original?



$s =<<
     
    

Brother, I haven't done PHP. Don't be so complicated.

In fact, I want to be very simple, that means

$datas = $_post["Shujuku"]; I've got a string sent to $datas that string is yybb_xdf. That's what it looks like.

I need to put this $datas in accordance with my request. The string between _ and. is assigned to a new variable.

Preg_match ('/_ (. +?) \./s ', $data, $m); $a = $m [1];  $a is the variable you want.

Preg_match ('/_ (. +?) \./s ', $data, $m); $a = $m [1];  $a is the variable you want.


Brother.. Only one point ...

I took the. Before and after the letter I now use your last variable $ A to marry only one.

No way, just post your code to see it.

I don't like the regular, so intercept.

$a = "yybb_cx."; $a = substr (substr ($a, 5), 0,-1); Echo $a;

No, I got it wrong. should not be. before. Only need to underline the letter can!!!

$a = "yybb_cx."; $a = substr ($a, 5); Echo $a;

$s = ' yybb_cx. '; Strtok ($s, ' _ '); $a = Strtok ('. '); echo $a; Cx
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.