<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>regex on Tutes Club</title><link>https://tutes.in/tag/regex/</link><description>Recent content in regex on Tutes Club</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 07 Jan 2020 08:21:08 +0000</lastBuildDate><atom:link href="https://tutes.in/tag/regex/index.xml" rel="self" type="application/rss+xml"/><item><title>Removing extra digits after decimal and leave only two decimal places</title><link>https://tutes.in/removing-extra-digits-after-decimal-and-leave-only-two-decimal-places/</link><pubDate>Mon, 12 Nov 2018 21:27:44 +0000</pubDate><guid>https://tutes.in/removing-extra-digits-after-decimal-and-leave-only-two-decimal-places/</guid><description>&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;^(.*?\..?.?).*?$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;your first match will leave the number with max 2 decimal digits.&lt;br&gt;
So find with &lt;code&gt;^(.*?\..?.?).*?$&lt;/code&gt; and replace with &lt;code&gt;\1&lt;/code&gt;&lt;/p&gt;
&lt;h3 id="input"&gt;Input&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;27485.0375
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;75777.9125
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;10785.0125
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;13822.5
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;26700
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;41194.375
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;9375
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4354.225
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;11564.475
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;12430.1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3246.4875
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;11596.3375
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;22466.0375
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="output"&gt;Output:&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;27485.03
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;75777.91
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;10785.01
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;13822.5
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;26700
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;41194.37
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;9375
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;4354.22
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;11564.47
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;12430.1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;3246.48
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;11596.33
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;22466.03
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Extracting names from given list of URLs (using regex)</title><link>https://tutes.in/extracting-names-from-given-list-of-urls-using-regex/</link><pubDate>Thu, 09 Aug 2018 08:14:35 +0000</pubDate><guid>https://tutes.in/extracting-names-from-given-list-of-urls-using-regex/</guid><description>&lt;h5 id="let-us-extract-name-form-the-url"&gt;let us extract name form the URL&lt;/h5&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.google.com/name?=rajiv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h5 id="paste-the-url-in-the-notepad-and-press-crtlf--and-select-regular-expressions--from-search-mode"&gt;paste the URL in the notepad and press crtl+f , and select ‘regular expressions ‘ from search mode&lt;/h5&gt;
&lt;p&gt;&lt;a href="https://tutes.in/wp-content/uploads/2018/08/find.jpg"&gt;&lt;img alt="find in notepad" loading="lazy" src="https://tutes.in/wp-content/uploads/2018/08/find.jpg"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h5 id="now-enter-the-regex-in-the-find-tab-to-fetch-names"&gt;now, enter the regex in the find tab to fetch names&lt;/h5&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;.*?\?=(\w+)$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, the selected name will be fetched form regex as (\1).&lt;/p&gt;
&lt;p&gt;it can work on numerous links like:-&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;https://www.google.com/name?=rajiv/
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/asdas?=borde/id=?
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/asdasd?=bordex
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/name?=bordet
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/asdasd?=border
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/jsciloji?=bordeeeee
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/name?=bordee
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/name?=bordeeeeeee
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/09328e?=bordeeee
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/name?=borde
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;http://www.example.com/lpaosd?=borde
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And only the part after first “?=” will be fetched&lt;/p&gt;</description></item><item><title>Commonly used regular expressions (regex) for developers in PHP</title><link>https://tutes.in/commonly-used-regular-expressions-regex-for-developers-in-php/</link><pubDate>Sun, 15 May 2016 10:54:44 +0000</pubDate><guid>https://tutes.in/commonly-used-regular-expressions-regex-for-developers-in-php/</guid><description>&lt;p&gt;Commonly used regular expressions (regex) for developers in PHP&lt;/p&gt;
&lt;p&gt;Regex are used or can be used almost everywhere strings are involved. If you are dealing with text strings, you would often find patterns in them and you might be required to filter few of them based on some similarities and properties. For example: a currency or money is often written in this form –&lt;br&gt;
[Currency symbol] [Digits] ([.] [Digits])maybe&lt;/p&gt;
&lt;p&gt;Now, in order to filter any such things programmatically using a script, few of really helpful regular expressions are mentioned below:&lt;/p&gt;</description></item></channel></rss>