<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Regexp on Laïla Atrmouh</title>
    <link>/en/tags/regexp/</link>
    <description>Recent content in Regexp on Laïla Atrmouh</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>&lt;a href=&#34;https://creativecommons.org/licenses/by-nc/4.0/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;CC BY-NC 4.0&lt;/a&gt;</copyright>
    <lastBuildDate>Sun, 10 Jan 2016 16:51:21 +0000</lastBuildDate>
    <atom:link href="/en/tags/regexp/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Extract characters after the last dash of a String RegExp</title>
      <link>/en/posts/2016/01/extract-characters-after-the-last-dash-of-a-string-regexp/</link>
      <pubDate>Sun, 10 Jan 2016 16:51:21 +0000</pubDate>
      <guid>/en/posts/2016/01/extract-characters-after-the-last-dash-of-a-string-regexp/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;👴 &lt;em&gt;Careful&lt;/em&gt; You&amp;rsquo;re reading an old article ! Some links might be broken and content may be outdated&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I wanted to extract characters after the last dash of a string. Regular expression are such a powerful tool to use in these cases. Here’s the one I needed for my problem :&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;(\w+)[^-]*$&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Please note that with PHP, you need to use the preg_match method and surround the regexp with slashes.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;preg_match&lt;/span&gt; (&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;/(\w+)[^-]*$/&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;cgo3020-red-xs&amp;#39;&lt;/span&gt;, $results); &lt;span style=&#34;color:#75715e&#34;&gt;// returns xs in $results[0]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here’s a pretty convenient tool to test your regexp:  https://regex101.com/&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
