{"id":25077,"date":"2016-09-20T03:01:21","date_gmt":"2016-09-19T17:01:21","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=25077"},"modified":"2016-09-19T22:26:10","modified_gmt":"2016-09-19T12:26:10","slug":"parsing-url-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/parsing-url-primer-tutorial\/","title":{"rendered":"Parsing Url Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.html\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Parsing Url Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.jpg\" title=\"Spliced Audio Number Genericization Tutorial\"  style=\"float:left;\"   \/><\/a><p class=\"wp-caption-text\">Parsing Url Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.html_GETME\" title=\"parse_url.html\">parse_url.html<\/a> HTML and Javascript web application is intended to show the power, and simplicity of use, of the Javascript function <a target=_blank title='Javascript split information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/jsref_split.asp'><i>split<\/i><\/a> to parse strings that have many component elements.  The example used in the web application is to parse web address URLs but this Javascript <i>split<\/i> usage can be applied to many different and varied ways to make things happen with web client Javascript code.<\/p>\n<p>In the spirit of <a target=_blank title='Linux or Unix piping information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Pipeline_(Unix)'><i>piping<\/i><\/a> with Linux or Unix (or Windows via piping in Windows Batch file scripting scenarios) we&#8217;ve talked about here a bit at this <a target=_blank title='Piping blog postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/piping'>blog<\/a>, we like to think of <i>split<\/i> as Javascript&#8217;s &#8220;relay racer&#8221; for &#8220;horizontal coding&#8221;.  To us, &#8220;horizontal coding&#8221; is a style of coding where we don&#8217;t worry that a piece of code disappears off to the right of the screen, to us as much as anything, because it is far more important to us to use those &#8220;relay racer&#8221; mechanisms to have a few lines of greatly impactive codelines, rather than trying to make it all fit into a screenwidth of reading.  In any case, in our increasingly mobile age, what does a &#8220;screenwidth&#8221; amount to anymore?<\/p>\n<p>We&#8217;d also argue that Javascript <i>split<\/i> &#8220;relay racing&#8221; style code <b>such as<\/b> used (to make the action property of an HTML form send the resultant GET method navigation, back to where it came from) in &#8230;<\/p>\n<p><code><br \/>\nvar formstr=\"&lt;br&gt;&lt;div style='width:100%;text-align:center;background-color:yellow;'&gt;&lt;form action='\" + <b>document.URL.split('?')[0].split('#')[0]<\/b> + \"' method='GET'&gt;&lt;br&gt;&lt;br&gt;&lt;\/form&gt;&lt;\/div&gt;&lt;br&gt;\";<br \/>\n<\/code><\/p>\n<p> &#8230; to us, is probably more self explanatory than &#8230;<\/p>\n<p><code><br \/>\n<b>var durlarr=document.URL.split('?');<br \/>\nvar durltwoarr=durlarr[0].split('#');<br \/>\nvar durlstr=durltwoarr[0];<\/b><br \/>\nvar formstr=\"&lt;br&gt;&lt;div style='width:100%;text-align:center;background-color:yellow;'&gt;&lt;form action='\";<br \/>\nformstr += <b>durlstr<\/b>;<br \/>\nformstr += \"' method='GET'&gt;&lt;br&gt;&lt;br&gt;&lt;\/form&gt;&lt;\/div&gt;&lt;br&gt;\";<br \/>\n<\/code><\/p>\n<p> &#8230; because we are used to reading, and looking for more across the screen, and &#8220;relay racing&#8221; style code prepares the reader for a related more complex bit of code on which the emphasis of their concentration should fall anyway.  It is for this same reasoning we love fairly complex Linux and Unix piping scenarios in (Korn) Shell code as well.  Of course, this is just one opinion, and there are contrary arguments as well.<\/p>\n<p>So what is being &#8220;relay raced&#8221; when Javascript <i>split<\/i> works this way?  A Javascript <i>string<\/i> is being passed in memory.  In contrast it is input and output <i>streams<\/i> normally being passed during Linux and Unix piping operations.  <i>Stream<\/i> is such an apt word for this <i>flowing<\/i> (or &#8220;relay racing&#8221;) software coding style.  It feels co-operative to work this way with tried and tested software coding components.<\/p>\n<p>Anyway, why don&#8217;t you try parsing some URLs with today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.html_GETME\" title=\"parse_url.html\">parse_url.html<\/a> <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.html\" title=\"Click picture\">live run<\/a>?   Or peruse this quite complex example from a recent blog posting mentioned in <a target=_blank title='Spliced Audio Number Genericization Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/spliced-audio-number-genericization-tutorial\/\/'>Spliced Audio Number Genericization Tutorial<\/a> <a target=_blank title='Complex parsing' href='http:\/\/www.rjmprogramming.com.au\/HTMLCSS\/parse_url.html?url=http%3A%2F%2Fwww.rjmprogramming.com.au%2FHTMLCSS%2Faudio_1_59.htm%3FnotAudio_Numbers%3DCounting%2BNumbers%2Bto%2B100%26notHear_this____%3DHear%2Byour%2Bnumber%26notHour%3Dtens%26notMinute%3Ddigits%26notContext%3D%26soundpath%3D%26notmidnight%3D%26noth1%3D1%26noth11%3D9%26notmidday%3D%26noto_clock%3D0%26notm1%3D1%26notm59%3D9%26not%3D%26notam%3D%26notpm%3D%26notsoundfile1%3Done_to_fiftynine.m4a%26notsoundfile2%3Dpast_quarterto.m4a%26notsoundfile3%3Dam_pm.m4a%26notsoundfile4%3Dmidnight_midday.m4a%26showform%3Don%23top'>yesterday<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d25077' onclick='var dv=document.getElementById(\"d25077\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/javascript\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d25077' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today&#8217;s parse_url.html HTML and Javascript web application is intended to show the power, and simplicity of use, of the Javascript function split to parse strings that have many component elements. The example used in the web application is to parse &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/parsing-url-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37],"tags":[103,576,652,900,1639,997,2013,1319,1345],"class_list":["post-25077","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-array","tag-html","tag-javascript","tag-parsing","tag-piping","tag-programming","tag-split","tag-tutorial","tag-url"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25077"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=25077"}],"version-history":[{"count":11,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25077\/revisions"}],"predecessor-version":[{"id":25092,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/25077\/revisions\/25092"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=25077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=25077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=25077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}