<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aniket Mitra on Medium]]></title>
        <description><![CDATA[Stories by Aniket Mitra on Medium]]></description>
        <link>https://medium.com/@aniketmitra1997?source=rss-2784c6ed5905------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mjTVGYkF1IwJ8Mlgups6YA.jpeg</url>
            <title>Stories by Aniket Mitra on Medium</title>
            <link>https://medium.com/@aniketmitra1997?source=rss-2784c6ed5905------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:28:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aniketmitra1997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Methods of Study Designs- Observational Studies & Surveys]]></title>
            <link>https://medium.com/data-science/methods-of-study-designs-observational-studies-surveys-22f0a04c7446?source=rss-2784c6ed5905------2</link>
            <guid isPermaLink="false">https://medium.com/p/22f0a04c7446</guid>
            <category><![CDATA[observational-studies]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[data-collection]]></category>
            <category><![CDATA[surveys]]></category>
            <category><![CDATA[bias]]></category>
            <dc:creator><![CDATA[Aniket Mitra]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 23:39:44 GMT</pubDate>
            <atom:updated>2020-01-09T23:40:00.220Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn About How to Design Studies with Real-World Examples for Effective Data Analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*3I3MW-E_bzhr_QIvAOEU_w.jpeg" /></figure><blockquote>Data is very important nowadays to study on a particular topic. So we should take care to record data in the correct manner so as to avoid getting the wrong result/inference. Also, we should do the correct study/experiment with that data to draw the right inference from them. We will discuss here those methods briefly.</blockquote><p>Studies can be done particularly in <strong>3</strong> ways, of which we will discuss only two here:</p><ol><li><strong>Observational Study: </strong>Studies in which our variable of interest is recorded as occurring <em>naturally </em>without any <em>experimenter’s/researcher’s interference</em>. Suppose we want to deduce whether students prefer listening to music during studying for better memory. We gather some students and ask them to record down if in the last/previous week they listened to music while studying for better memory. Another way is that we ask them to keep a note of whether they are listening to music in the future week while study.</li></ol><p>In both cases, we are recording the natural behavior/tendency of a student while he is studying and we are not interfering with their behavior in any way like forcing them to listen to music, etc. So we can call this study <em>Observational Study</em>.</p><p>Again note, in the first scenario we are recording past events. So we call it <strong><em>Retrospective Observational Study</em></strong>. In the second scenario, we are recording events in the future so we call them <strong><em>Prospective Observational Study</em></strong>.</p><p>In Observational studies, there can be the effect of one or more external variables that we do not take into account but can affect our results badly. Such a variable is also called <strong><em>Lurking Variable</em></strong>. For example, suppose we want to observe which method is ideal for citizens to quit drugs- <strong>a.) </strong>taking some medicines/anti-drugs after consulting a doctor or <strong>b.)</strong> simply doing nothing or not taking any doctor’s advice.</p><p>Let surprisingly our results show that, <em>doing nothing</em> gives a better result. It might be because those who do nothing and not go to the doctor have a stronger <em>desire/willpower</em> to quit drugs. So desire becomes a <em>lurking variable</em> here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G39zVL01wkrfwhCGE5POTw.png" /><figcaption>Effect of Lurking Variable on Studies</figcaption></figure><p>2. <strong>Sample Surveys</strong>: Here, individuals report their values for the variable being tested <em>themselves</em> to the researcher through some means. These means include <em>persons visiting from house to house and recording observations</em>, sending <em>questionnaires through email</em>, <em>telephonic interviews</em>,<em> internet surveys, </em>etc.</p><p><strong><em>Bias</em></strong> is a big issue in the case of surveys. Unfairness in the methodology in which collecting data/records is called <em>bias</em>. It is a serious problem in surveys and results in the deduction of wrong inference from collected data.</p><p>Let us first discuss some common type of biases we come across in surveys:</p><p><strong>Convenience Bias or Convenience Sample:</strong> Chosen solely in accordance with the convenience of the person conducting the survey. Suppose you want to take feedback on a particular product from the customers who bought it. But you only ask feedback from the first 50 buyers for your convenience. Now it is wrong because it might be the case that the last few buyers have got defective products. So we are neglecting them. The best way is to choose people at random.</p><p><strong>Volunteer/ self-selected Bias:</strong> Here individuals themselves choose to be part of the survey. Suppose, a survey is going on to calculate the average income of a particular place. The participants have to come to the survey center and record their income. Obviously successful and higher-income people will go spontaneously to record their income but lower-income people may feel shy to disclose their income. Here only higher-income people are volunteering to participate in the survey so we won’t get the real estimate of the average income of the particular place.</p><p><strong>Non-response Bias</strong>: Where individuals fail to complete or return their survey response form or refuse to answer. In the above example, lower-income people refuse to be part of the survey causing non-response bias.</p><p><strong>Response Bias: </strong>Individuals take the survey but don’t answer the questions correctly. Suppose after an election, a survey is done to call the people and ask if they have cast their votes. Now, after the survey, it was found that the number of people who said <em>yes</em> is much more than the public record. Clearly here many participants have lied i.e, said <em>yes </em>in spite of not casting their vote because they want to be deemed as a <em>responsible citizen</em> of the country as all responsible citizens cast votes.</p><p><strong>Undercoverage Bias:</strong> The survey doesn’t include appropriate representation from certain groups in a target population. Eg: Suppose the authority of a school is conducting a survey for assessing the quality of the teacher for each grade. But they forget to include 7th and 8th Grade. So not all grades of a school are included in the survey. This is <em>undercoverage bias</em>.</p><h4>Types of Questions in Surveys:</h4><ol><li><strong>Open Questions: </strong>It can have infinite answers. Eg: <em>What is your favorite topic of learning?</em> It can have many answers from very general like <em>Computer Science</em> to very specific like <em>Deep Learning</em>.</li><li><strong>Closed Questions:</strong> Intended to have specific answers. Eg: <em>What is your favorite topic? Is it Machine Learning, Deep Learning or Reinforcement Learning?</em></li></ol><p>While forming questions for the survey, it should be remembered that:</p><p>a. Open questions are less restrictive but the answers/responses can be difficult to summarize.</p><p>b. Closed question has a high chance of being bias.</p><p>c. Questions should be neutral, and it should not influence the answer to any upcoming question, easy to understand and should be able to extract honest responses from participants.</p><p><strong>Note:</strong> Sometimes in the options provided for the questions we often see options like “<strong>don’t know</strong>” or “<strong>choose not to answer</strong>”. The former is used when the participant is unaware of the topic or has forgotten about the topic.</p><p>“<em>choose not to answer</em>” is used when a sensitive/offensive/embarrassing question is asked. Eg: For any medical-related or AIDS-related survey, they ask <em>What protective measure you take while having intercourse?</em> Many may find it embarrassing to answer the question.</p><p>What is wrong with the question “<em>Do you go to Amazom.com frequently and do you indulge in online shopping frequently?</em>”</p><p>It has two questions in one so it might confuse participants to choose their answer as many participants would use <em>Amazon.com</em> but do online shopping rarely while others do frequent online shopping but from other sites like <em>Snapdeal</em> etc.</p><h4>Reference:</h4><ol><li><a href="https://www.amazon.in/Statistics-Practice-Problems-Dummies-Online-ebook/dp/B00LV5MROU">Statistics for Dummies</a></li><li><a href="https://lagunita.stanford.edu/courses/OLI/StatReasoning/Open/about">Statistical Reasoning Course by Stanford Ligunita</a>.</li><li>Lectures from Udacity Bertelsman Scholarship Challenge- Data Track</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22f0a04c7446" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/methods-of-study-designs-observational-studies-surveys-22f0a04c7446">Methods of Study Designs- Observational Studies &amp; Surveys</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Bayesian Network]]></title>
            <link>https://medium.com/data-science/basics-of-bayesian-network-79435e11ae7b?source=rss-2784c6ed5905------2</link>
            <guid isPermaLink="false">https://medium.com/p/79435e11ae7b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bayesian-statistics]]></category>
            <dc:creator><![CDATA[Aniket Mitra]]></dc:creator>
            <pubDate>Mon, 19 Aug 2019 21:28:44 GMT</pubDate>
            <atom:updated>2019-08-19T21:28:44.742Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>There is innumerable text available in the net on Bayesian Network, but most of them are have heavy mathematical formulas and concepts thus quite difficult to understand. Here, I have tried to explain the topic as simple as possible with minimum equations and a real-world example.</p><h4>Basic Concept</h4><p><strong>Bayesian Network</strong> is a very important tool in understanding the dependency among events and assigning probabilities to them thus ascertaining how probable or what is the change of occurrence of one event given the other. For example, suppose you are getting scolded at school by your teacher for being late and there could be many reasons for being late like waking up late, traffic jams, etc. So here, scolding is dependent on the events like waking up late or traffic jam i.e., these reasons have a direct influence on you being scolded. This can be efficiently represented using Bayesian Network which we will see soon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Zf8S1NI8wgKZmme2OwsHg.png" /><figcaption>Fig. 1</figcaption></figure><p>Let <em>{X1, X2,…….Xn}</em> be some events just like being scolded, waking up late etc. In Bayesian Network, they can be represented as nodes. Now if a node has some dependency on another node then an arrow/arc is drawn from one node to another as shown in <strong>fig.1</strong>. It is interpreted as the child node’s occurrence is influenced by the occurrence of its parent node. So Bayesian Network represents a <strong>directed acyclic graph(DAG)</strong>. It is not allowed to form cyclical patterns within nodes so it is <strong>acyclic</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cygb1Qsewi_37nD2D1GZdQ.png" /><figcaption>Fig. 2: The Formula for Joint Probability Distribution</figcaption></figure><p>Now using <em>Conditional probability</em> and <strong>chain rule</strong>, we can easily get the full joint distribution i.e., the probability of the final event given all other dependent events.<em> (Note: If you are unsure of conditional probability and chain rules, follow these </em><a href="https://youtu.be/HVlXEwVD8dw"><em>lectures</em></a><em>. They are the extensive resources to learn probability and Bayesian Statistics.) </em>From the equation, we can see the probability of child nodes depends on its immediate parents. Note: <strong>π</strong> denotes product sign.</p><p>Using the above formulas we can derive the joint probability distribution formula of the below models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgm8kzKUY_QHTM8KdP0Fkg.png" /><figcaption>Fig. 3</figcaption></figure><p>So the results of the joint probability estimation of the above-given networks can be easily found using the formula given in <strong>Fig.2</strong>.</p><h3>Real-World Example of Bayesian Network Model</h3><p>Now let us wrap up the tutorial with a real-world example for better understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g19ZghXEpuxkBRL2_Kszyg.png" /><figcaption>Fig. 4</figcaption></figure><p>Let, <strong>P(A) denotes the event that you wake up late in the morning.</strong></p><p><strong>P(B) denotes the event you are late for school.</strong></p><p><strong>P(C) denotes the event you are scolded by your teacher.</strong></p><p><strong>P(D) denotes the event there is a traffic jam on the road</strong></p><p><strong>P(E) denotes the event your father boards the public bus every morning.</strong></p><p><strong>P(F) denotes the event your father goes to office.</strong></p><p>So what is the probability that you are scolded at school? Now, you can easily find that out using the formula. So the final result becomes <strong>P(C|B).P(B|A,D).P(D).P(A)</strong></p><p>Hey, but wait!!! What about P(E) and P(F) ??? They are also present there in the model. Remember, two events which are not connected with each other with arcs directly or indirectly given any other node are called independent events and occurrence of one has no effect on the occurrence of another. We can safely predict from the model the value of <strong>P(C|F)</strong> i.e., the probability you being scolded because of the event that your father is going to office is <strong>0</strong>.</p><p>The probability value for each node given their parent node is represented in the form of a table called <strong>Conditional Probability Table(CPT)</strong>. The below example is a representation of CPT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*0BTzommpUoMfNBFDxvJ5sg.png" /><figcaption>Fig. 5: Conditional Probability Table (<strong>Creator: </strong>Muhammad Nazim Razali)</figcaption></figure><blockquote>Bayesian Network has a huge application in the real world. Given a symptom, a Bayesian Network can predict the probability of a particular disease causing the symptoms. Also by taking the evidence collected from two crime scenes, Bayesian Network can give the investigation team valuable insights on whether the criminals at two places are related or not.</blockquote><p>Some MOOCs to explore more on Bayesian Networks:</p><p>1. <a href="https://www.coursera.org/specializations/probabilistic-graphical-models">Probabilistic Graphical Model</a> by <em>Stanford University</em></p><p>2. <a href="https://www.coursera.org/learn/bayesian-methods-in-machine-learning">Bayesian Methods for Machine Learning</a> by <em>National Research University Higher School of Economics</em></p><p>3. <a href="https://www.coursera.org/learn/bayesian-statistics">Bayesian Statistics: From Concept to Data Analysis</a> by <em>University of California, Santa Cruz</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79435e11ae7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/basics-of-bayesian-network-79435e11ae7b">Basics of Bayesian Network</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regular Expression Made Easy Part- 2]]></title>
            <link>https://medium.com/@aniketmitra1997/regular-expression-made-easy-part-2-c3d08d50c08b?source=rss-2784c6ed5905------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3d08d50c08b</guid>
            <category><![CDATA[data-extraction]]></category>
            <category><![CDATA[extraction]]></category>
            <category><![CDATA[regex]]></category>
            <category><![CDATA[regular-expressions]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Aniket Mitra]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 22:17:13 GMT</pubDate>
            <atom:updated>2019-08-05T22:20:58.961Z</atom:updated>
            <content:encoded><![CDATA[<p>In Part-1, I introduced Regular Expressions and discussed some basic operations. Here we will discuss some advanced functionality of regular expressions.</p><p>Suppose we want to find the common article ‘<strong>the</strong>’ but it is mixed with some special words like’ <strong>the_</strong>’ or ‘<strong>the25</strong>’ etc. In that case, to also find such expressions we use /<strong>[ˆa-zA-Z][tT]he[ˆa-zA-Z]</strong>/ . Here as we can see from the syntax, it will match characters like underscores, digits on both sides of ‘<strong>the</strong>’ but not any other alphabets. This is done to prevent matching words like ‘<strong>either</strong>’, ‘<strong>neither</strong>’ etc which contains ‘<strong>the</strong>’ inside them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Vo09Y3fSOObMec8dylYjTw.jpeg" /><figcaption>Image Source: Internet</figcaption></figure><p>But will the syntax match ‘<strong>The</strong>’ at the beginning of any sentence. No! To do that we need to modify the regular expression to /<strong>(ˆ|[ˆa-zA-Z])[tT]he([ˆa-zA-Z]|$)/. </strong>So now it can match ‘<strong>The</strong>’ both at the beginning of a sentence or at any other place of the sentence.</p><p>Note: if the syntax matches words like ‘<strong>either</strong>’, ‘<strong>neither</strong>’ or ‘<strong>other</strong>’ then the type of error is called <strong>false positive</strong> and if it fails to match ‘<strong>the</strong>’ for which it is actually made the error is called <strong>false negative</strong>.</p><p>Suppose we want to match expressions like <strong>&lt;44&gt;</strong> i.e, numbers within boxes. The correct syntax to do this will be /<strong>([0–9]+)/&lt;\1&gt;</strong>/.Here <strong>\1</strong> will refer to that part of syntax which is within parenthesis. So since we gave here the instance of one or more occurrence of digits in parenthesis, so it would match any numerical value. And since we are putting <strong>\1</strong> within boxes in the regular expression, it denotes that we want to find any numerical value enclosed in boxes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*SyrVgI23LrFvRHWAWcm9Fg.jpeg" /><figcaption>Image Source: Internet</figcaption></figure><p>Let us consider the sentence <em>The faster they run, the faster they reach</em>. To automatically insert the second ‘<em>faster’</em> in the sentence we can write <strong><em>The (.*)er they run, the \1er they reach</em></strong>. Like the above example here the <strong>\1</strong> will match the expression given in parenthesis. So if the word given in parenthesis is ‘<strong>faster</strong>’, it will also give ‘<strong>faster</strong>’ in second case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*c3ZiUn36qvlHPPVj2h3kyQ.jpeg" /><figcaption>Image Source: Internet</figcaption></figure><p>To match two parentheses we have a similar procedure. Let us take the sentence <em>The faster they run, the faster their friends run</em>. We can use the expression /<strong>the (.*)er they (.*), the \1er their friends\2</strong>/ matches ‘<strong>faster</strong>’ for <strong>\1</strong> and ‘<strong>run</strong>’ for <strong>\2</strong>.</p><p>The<strong> lookahead assertion (?=) </strong>is used to stop the match pointer once a particular string is encountered. Eg: /<strong>(?=Boy)[A-Za-z]+</strong>/ will stop immediately if the word ’<strong>Boy’ </strong>is found in the sentence and won’t advance further. Here the syntax after finding the word ‘<strong>Boy</strong>’ in a sentence stops searching further. Similarly, /<strong>ˆ(?!Boy)[A-Za-z]+</strong>/ matches at the beginning of a sentence any word that does not start with ‘<strong>Boy</strong>’.</p><p>ELIZA one of the earliest chatbot which heavily use regular expressions for its operation. Let us take an example:</p><h4>User: You don’t argue with me.</h4><h4>ELIZA: WHY DO YOU THINK I DON’T ARGUE WITH YOU</h4><p>So from the answer given by ELIZA,we can get a hint that the chatbot it has a series/ collection of regular expressions which matches and changes some part of the query given by the user and produce an answer.</p><p>So the rule for the above-given example would be to change every instance of ‘<strong>YOU</strong>’ to ‘<strong>I</strong>’ and insert some extra words like ‘<strong>WHY DO YOU THINK</strong>’ and then match the given string as it is.</p><blockquote>The writing has been heavily inspired by the book ‘Speech and Language Processing’ by Jurafsky and Martin which is freely available online to download. To use regular expressions in Python refer to the series of tutorials: <a href="https://www.youtube.com/watch?v=VU60rEXaOXk&amp;list=PLGKQkV4guDKH1TpfM-FvPGLUyjsPGdXOg">https://www.youtube.com/watch?v=VU60rEXaOXk&amp;list=PLGKQkV4guDKH1TpfM-FvPGLUyjsPGdXOg</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3d08d50c08b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regular Expression Made Easy Part- 1]]></title>
            <link>https://medium.com/@aniketmitra1997/regular-expression-made-easy-part-1-7063d87f92d6?source=rss-2784c6ed5905------2</link>
            <guid isPermaLink="false">https://medium.com/p/7063d87f92d6</guid>
            <category><![CDATA[regular-expressions]]></category>
            <category><![CDATA[text-mining]]></category>
            <category><![CDATA[extract]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[regex]]></category>
            <dc:creator><![CDATA[Aniket Mitra]]></dc:creator>
            <pubDate>Sun, 04 Aug 2019 05:26:08 GMT</pubDate>
            <atom:updated>2019-08-04T05:26:08.443Z</atom:updated>
            <content:encoded><![CDATA[<p>Regular Expression Made Easy Part- 1</p><p>Extracting important information from data requires certain expertise and tools to do it efficiently. Regular Expression is one such tool which is immensely used to extract important information from large texts.</p><blockquote>Well, let us see an example. You have a large online newspaper text on a particular natural disaster and you want to extract figures like how many casualties, how many missing, how much worth of property damaged, etc. These are number like <strong>100, 200, 20000</strong> etc. To specifically extract, such numerical figures from large, newspaper report regular expression can be efficiently used.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*AZXud4aK_ZODUnP3_CTtDg.png" /><figcaption>Image Source: Internet</figcaption></figure><p>We will see here just the syntax of the regular expression of PERL Language. But most of the other language has almost the same syntax.</p><p><strong>1.</strong>Finding a particular word in large text — <strong>/casualties/</strong> will find all the word ‘casualties’ in the text. Eg:<em> There are 100 casualties recorded yet. </em>Note ‘<em>/</em><strong>’ </strong>are symbols used in PERL language.</p><p>But what if the sentence is “<em>So far only one casualty has been recorded from the scene.</em>” ?</p><p>No, our regular expression will fail to catch ‘<strong>casualty</strong>’ here. We will use here <strong>/casualt[y|ies]/</strong> which will match our desired text. It works in the manner that that after checking for ‘<strong>casualt</strong>’, it will match either ‘<strong>y</strong>’ or ‘<strong>ies</strong>’ whichone is present, thus serving our purpose.</p><p>Suppose we want to determine how many animals got killed. Now in the text contains both words ‘<strong>animal</strong>’ and ‘<strong>animals</strong>’ . Here we will use <strong>/animals?/</strong> which means zero or one instance of previous character i.e., ‘<strong>s</strong>’. So it will match if there are zero ‘<strong>s</strong>’ i.e.only ‘<strong>animal</strong>’ or ‘<strong>s</strong>’ present i.e.’ <strong>animals</strong>’.</p><p>2. ‘<strong><em>200</em></strong><em> people are missing and properties worth </em><strong><em>Rs. 20,000</em></strong><em> is damaged in the flood</em>’. How to match the numerical stats here? using syntax <strong>/[0–9]/ </strong>can<strong> </strong>match any number 0,1,2,3,4,5,6,7,8,9 . But wait will it match <strong>20,000</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*uUBq0H88ndOCIV1deLtSOA.jpeg" /><figcaption>Image Source: Internet</figcaption></figure><p>NO. To match <strong>20,000</strong> we can add <strong>/[0–9,]/</strong> . Any special character you add to the syntax, it will be matched along with the number. So if its, <strong>20.000</strong> use syntax <strong>/[0–9.]/</strong>.</p><p>Similarly, we can use <strong>/[a-z]/</strong> to match all any word as this syntax matches all instances containing from a to z thus matching any word. <strong>/[A-Z]/</strong> is used to match uppercase letters only. Alternatively, we can use <strong>\d</strong> for denoting digits, <strong>\w</strong> for denoting words. so <strong>/\d{2,6}/</strong> will extract digits. But wait! What is there within curly brackets?? <strong>/{n,m}/</strong> specifies the range of numbers to be extracted. So here <strong>{2,6}</strong> means we can want to extract a number containing at least 2 digits or at most 6 digits. Eg: <strong>222</strong> can be extracted by this regular expression but not <strong>2</strong> or <strong>2222222</strong>. If you are not sure how long the number would be but you know it will be at least 2-digit long use <strong>/\d{2,}/</strong>.</p><p>Suppose we want to extract all three-letter words beginning with ‘h’ and ending with ‘t’ like <strong>hat, hit, hot, </strong>etc. Now an easy way to do this will be <strong>/h.t/</strong> where . is a wildcard expression that matches any single character. So to extract ‘<strong>heat’</strong> the regular expression will be <strong>/h..t/</strong>. Don’t confuse it with <strong>/hat\./</strong> . Here we can be extracting <strong>hat. </strong>i.e. the full-stop also or all those instances where sentence end with word <strong>hat</strong>.</p><p><strong>\b </strong>matches the word boundary. Eg: <strong>/\b88\b/</strong> will only match <strong>88</strong>, not<strong> 388</strong> but <strong>/88/</strong> also match <strong>388</strong> due to greedy nature of the algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*6CAw2M0WrPNEX2B696n3bQ.png" /><figcaption>Image Source: Internet</figcaption></figure><p>Caret symbol <strong>^</strong> matches the start of a line. The pattern <strong>/^An/</strong> specifies a sentence that begins with the article ‘<strong>An</strong>’. But remember <strong>/[^(An)]/</strong> is different. It will match anything except ‘An’. Notice the difference in square brackets here. Eg: <em>An eleplant is standing there</em>. The former regular expression will match ‘<strong>An</strong>’ here but the latter will fail to do so.</p><p>Similarly, <strong>$</strong> matches the end of the string. So to match a sentence that only ends with exclamation mark we would make a regular expression <strong>/\!$/</strong>.</p><p>Expression <strong>+</strong> is used to match at least one of the previous characters. For example: <strong>/ba+!/</strong> will match <strong>baa!</strong> or <strong>baaa!</strong> or <strong>baaaaaa!</strong> or anything similar.</p><p>Lastly, we discuss how to extract whitespaces. /s can be used to extract white spaces. Let us go back to the example <strong>Rs. 20,000</strong>. We can extract it using the expression <strong>/w{2}\.\s{1,}\d{1,}\,\d{1,}/</strong> .See here we are extracting the white space between ‘.’ and ‘<strong>2’</strong> using <strong>\s.</strong> If we are unsure of the number of spaces, digits or words we can use the range regular expression <strong>{n,}</strong> as shown above. It denotes minimum one character long but maximum could be anything.</p><blockquote>More complex expressions and real-world examples will be discussed in my next post. Best of luck and happy learning !!!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7063d87f92d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>