{"id":91547,"date":"2025-01-06T17:52:04","date_gmt":"2025-01-06T14:22:04","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/string-functions-examples-23g1\/"},"modified":"2025-01-06T17:52:04","modified_gmt":"2025-01-06T14:22:04","slug":"string-functions-examples-23g1","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/string-functions-examples-23g1\/","title":{"rendered":"\u0646\u0645\u0648\u0646\u0647 \u062a\u0648\u0627\u0628\u0639 \u0631\u0634\u062a\u0647 &#8211; \u0627\u0646\u062c\u0645\u0646 DEV"},"content":{"rendered":"<div data-article-id=\"2191383\" id=\"article-body\">\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>#1. L Strip\n#2. R Strip\n#3. Replace a string in a statement with another string\n\n# L Strip\nStr = input(\"Enter the String:\")\n\nord_space = ord(' ')\nord_tab = ord('\\t')\n\ni = 0 \nright = 0\nwhile i &lt; len(Str):\n    if ord(Str[i]) != ord_space and ord(Str[i]) != ord_tab:\n        right = i\n        break\n    i+=1\nStr = Str[right:]\nprint('LStrip String:',Str,end='#',sep='')\n\n\n# R Strip\n\nStr = input(\"Enter the String:\")\n\nord_space = ord(' ')\nord_tab = ord('\\t')\n\ni = len(Str)-1\nright = 0 \n\nwhile i &gt; 0:\n    if ord(Str[i]) != ord_space and ord(Str[i]) != ord_tab:\n        right = i\n        break\n    else:\n        i-=1\n\nStr = Str[:right+1]\n\nprint(\"#\", Str, \"#\", sep='')\n\n\n# Replace a string\n\n#MSD --&gt; Dhoni\n#MSD is Former Indian Captain.  MSD is retired. MSD plays for CSK\nsen = 'MSD is Former Indian Captain.  MSD is retired. MSD plays for CSK - MSD'\nKey = 'MSD'\nNew_sen = ''\nKey_Len = len(Key)\ni=0\nwhile i&lt; len(sen):\n       if Key == sen[i:i+Key_Len]:\n            print('i',i)\n            New_sen = New_sen + 'Dhoni'\n            i+=Key_Len\n       else:\n            New_sen = New_sen + sen[i]\n            i+=1\nprint(New_sen)       \n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>#1. L Strip #2. R Strip #3. Replace a string in a statement with another string # L Strip Str = input(&#8220;Enter the String:&#8221;) ord_space = ord(&#8216; &#8216;) ord_tab = ord(&#8216;\\t&#8217;) i = 0 right = 0 while i &lt; len(Str): if ord(Str[i]) != ord_space and ord(Str[i]) != ord_tab: right = i break i+=1 Str &hellip;<\/p>\n","protected":false},"author":2,"featured_media":91548,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-91547","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/91547","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=91547"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/91547\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/91548"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=91547"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=91547"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=91547"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}