{"id":6516,"date":"2019-10-11T10:30:53","date_gmt":"2019-10-11T08:30:53","guid":{"rendered":"https:\/\/blog.nevercodealone.de\/?p=6516"},"modified":"2020-04-22T16:16:07","modified_gmt":"2020-04-22T14:16:07","slug":"javascript-zahlen-aus-string-suchen","status":"publish","type":"post","link":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/","title":{"rendered":"Javascript Zahlen aus String suchen"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Es kann m\u00f6glich sein, das man in Javascript Zahlen aus String suchen und herausfiltern m\u00f6chte. Hier geht es auch zum Blog Post &#8222;<a href=\"https:\/\/blog.nevercodealone.de\/javascript-compare-strings-best-practice\/\" class=\"rank-math-link\">Javascript String Compare<\/a>&#8220; Diesen Anwendungsfall hatte ich bei einem <a href=\"https:\/\/www.rogoit.de\/webdesign-typo3-blog-duisburg\/category\/dalekjs\/\"><strong>DalekJS Test<\/strong><\/a> gehabt. In einem gro\u00dfen <strong>eCommerce-Projekt<\/strong>  werden damit Preise <a href=\"https:\/\/blog.nevercodealone.de\/team23-php-schulung\/\">getestet<\/a>. Die Berechnung der Mehrwertsteuer und  auch andere Zahlen. Dadurch erh\u00e4lt man mit wenigen Mitteln einen sehr  aussagekr\u00e4ftigen Test \u00fcber seine <strong>Webapplication<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Javascript Zahlen aus String suchen<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Mit dem folgenden <strong>Javascript-Code<\/strong> St\u00fcck wird das mit einen regul\u00e4ren Ausdruck erledigt.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> var valueSelect = $('#selectorid').text().match(\/&#91;0-9]+&#91;.,]&#91;0-9]+\/g)&#91;0];<\/code><\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"490\" src=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/dalekjs-frontend-testing.png\" alt=\"Javascript Zahlen aus String suchen - DalekJS\" class=\"wp-image-6521\" srcset=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/dalekjs-frontend-testing.png 325w, https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/dalekjs-frontend-testing-199x300.png 199w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><figcaption>Javascript Zahlen aus String suchen &#8211; DalekJS<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In der Codezeile wird also der Text aus einem <strong>DOM-Object<\/strong> gelesen und die einzelnen Zahlen als Array Values zur\u00fcck gegeben. Hier wird dann der <strong>JS-Variablen<\/strong> valueSelect das erste Array Element zur\u00fcck gegeben. Wie bereits erw\u00e4hnt handelt es sich hier und einen <strong>DalekJS-Frontend Test<\/strong> in einem <strong><a href=\"https:\/\/blog.nevercodealone.de\/code-talks-commerce\/\">eCommerce Projekt<\/a><\/strong>.  Der String ist also ungef\u00e4hr 324,45 Euro. Hier wird dann Euro  erfolgreich entfernt. Es k\u00f6nnte auch noch etwas vor der Zahl stehen.  Z.B. ein \u201enur\u201c oder \u201ejetzt\u201c.&nbsp;<a href=\"https:\/\/blog.nevercodealone.de\/teilnehmerrekord-hall-of-fame-event-begeistert-php-community\/\">Regul\u00e4re Ausdr\u00fccke<\/a> werden immer wieder  verwendet, damit gerade bei String Manipulation effektiv und schnell  gearbeitet werden kann.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Javascript match-Methode<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Bei der <strong>Javascript Dokumentation<\/strong>&nbsp;<a href=\"http:\/\/www.w3schools.com\/jsref\/jsref_match.asp\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">http:\/\/www.w3schools.com\/jsref\/jsref_match.asp<\/a> zur match-Methode ist auf der Seite von den W3SCHOOLS ein kleines Beispiel angegeben.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var str = \"The rain in SPAIN stays mainly in the plain\";\nvar res = str.match(\/ain\/g);\n\n\/\/RESULT &#91;ain,ain,ain]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/blog.nevercodealone.de\/javascript-compare-strings-best-practice\/\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"512\" src=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2020\/04\/Javascript-compare-strings.jpg\" alt=\"Javascript Compare Strings\" class=\"wp-image-7124\" srcset=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2020\/04\/Javascript-compare-strings.jpg 1024w, https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2020\/04\/Javascript-compare-strings-300x150.jpg 300w, https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2020\/04\/Javascript-compare-strings-768x384.jpg 768w, https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2020\/04\/Javascript-compare-strings-585x293.jpg 585w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Javascript Compare Strings<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In dem Beispiel sieht man, wie die 3 Vorkommen von \u201eain\u201c jeweils in ein Array Element gelegt werden. Bei unserem Regul\u00e4ren Ausdruck werden in dem ganzen String \/g alle Vorkommen von Zahlen gesucht. Also kann der Ausdruck auch auf Strings mit mehreren Zahlen angewendet werden.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Artikel Bildquelle Javascript Zahlen aus Sting suchen:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/mashable.com\/2012\/11\/12\/javascript\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (\u00f6ffnet in neuem Tab)\">http:\/\/mashable.com\/2012\/11\/12\/javascript\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Es kann m\u00f6glich sein, das man in Javascript Zahlen aus String suchen und herausfiltern m\u00f6chte.&hellip;<\/p>\n","protected":false},"author":1,"featured_media":6519,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"cybocfi_hide_featured_image":"","footnotes":""},"categories":[8,12],"tags":[91,42,46],"class_list":["post-6516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-qualitaet","category-webdevelopment-tools","tag-javascript","tag-tutorial","tag-webdevelopment"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Javascript Zahlen aus String suchen - HTML und CSS Tricks Webdesign<\/title>\n<meta name=\"description\" content=\"Javascript Zahlen aus Sting suchen also mir einem regul\u00e4ren Ausdruck filtern geht mit der hier aufgef\u00fchrten jQuery-Methode.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Zahlen aus String suchen - HTML und CSS Tricks Webdesign\" \/>\n<meta property=\"og:description\" content=\"Javascript Zahlen aus Sting suchen also mir einem regul\u00e4ren Ausdruck filtern geht mit der hier aufgef\u00fchrten jQuery-Methode.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/\" \/>\n<meta property=\"og:site_name\" content=\"Employer Branding und Tutorials Web Development\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/nevercodealone\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/roland.golla\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-11T08:30:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-22T14:16:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"702\" \/>\n\t<meta property=\"og:image:height\" content=\"336\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Roland Golla\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/cleancode_devel\" \/>\n<meta name=\"twitter:site\" content=\"@nevercodealone\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Roland Golla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Javascript Zahlen aus String suchen - HTML und CSS Tricks Webdesign","description":"Javascript Zahlen aus Sting suchen also mir einem regul\u00e4ren Ausdruck filtern geht mit der hier aufgef\u00fchrten jQuery-Methode.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/","og_locale":"de_DE","og_type":"article","og_title":"Javascript Zahlen aus String suchen - HTML und CSS Tricks Webdesign","og_description":"Javascript Zahlen aus Sting suchen also mir einem regul\u00e4ren Ausdruck filtern geht mit der hier aufgef\u00fchrten jQuery-Methode.","og_url":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/","og_site_name":"Employer Branding und Tutorials Web Development","article_publisher":"https:\/\/www.facebook.com\/nevercodealone\/","article_author":"https:\/\/www.facebook.com\/roland.golla","article_published_time":"2019-10-11T08:30:53+00:00","article_modified_time":"2020-04-22T14:16:07+00:00","og_image":[{"width":702,"height":336,"url":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","type":"image\/jpeg"}],"author":"Roland Golla","twitter_card":"summary_large_image","twitter_image":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","twitter_creator":"@https:\/\/twitter.com\/cleancode_devel","twitter_site":"@nevercodealone","twitter_misc":{"Verfasst von":"Roland Golla","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#article","isPartOf":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/"},"author":{"name":"Roland Golla","@id":"https:\/\/blog.nevercodealone.de\/#\/schema\/person\/abb634fbea84896d032351009372debb"},"headline":"Javascript Zahlen aus String suchen","datePublished":"2019-10-11T08:30:53+00:00","dateModified":"2020-04-22T14:16:07+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/"},"wordCount":287,"commentCount":1,"publisher":{"@id":"https:\/\/blog.nevercodealone.de\/#organization"},"image":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","keywords":["Javascript","Tutorial","Webdevelopment"],"articleSection":["Software-Qualit\u00e4t","Webdevelopment-Tools"],"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/","url":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/","name":"Javascript Zahlen aus String suchen - HTML und CSS Tricks Webdesign","isPartOf":{"@id":"https:\/\/blog.nevercodealone.de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#primaryimage"},"image":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","datePublished":"2019-10-11T08:30:53+00:00","dateModified":"2020-04-22T14:16:07+00:00","description":"Javascript Zahlen aus Sting suchen also mir einem regul\u00e4ren Ausdruck filtern geht mit der hier aufgef\u00fchrten jQuery-Methode.","breadcrumb":{"@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#primaryimage","url":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","contentUrl":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2019\/10\/javascript-string-integer-zahlen.jpg","width":702,"height":336,"caption":"Javascript String Integer Zahlen"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.nevercodealone.de\/javascript-zahlen-aus-string-suchen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/blog.nevercodealone.de\/"},{"@type":"ListItem","position":2,"name":"Javascript Zahlen aus String suchen"}]},{"@type":"WebSite","@id":"https:\/\/blog.nevercodealone.de\/#website","url":"https:\/\/blog.nevercodealone.de\/","name":"Employer Branding und PHP Training","description":"Employer Branding f\u00fcr Web Development Jobs, viele Tutorials und HowTo Gastbeitr\u00e4ge der Community","publisher":{"@id":"https:\/\/blog.nevercodealone.de\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.nevercodealone.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Organization","@id":"https:\/\/blog.nevercodealone.de\/#organization","name":"Never Code Alone","url":"https:\/\/blog.nevercodealone.de\/","logo":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/blog.nevercodealone.de\/#\/schema\/logo\/image\/","url":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2016\/03\/nca_2.png","contentUrl":"https:\/\/blog.nevercodealone.de\/wp-content\/uploads\/2016\/03\/nca_2.png","width":212,"height":130,"caption":"Never Code Alone"},"image":{"@id":"https:\/\/blog.nevercodealone.de\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/nevercodealone\/","https:\/\/x.com\/nevercodealone","https:\/\/www.instagram.com\/nevercodealone\/","https:\/\/www.youtube.com\/c\/NeverCodeAlone"]},{"@type":"Person","@id":"https:\/\/blog.nevercodealone.de\/#\/schema\/person\/abb634fbea84896d032351009372debb","name":"Roland Golla","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/blog.nevercodealone.de\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f142b13f7d2f172e4d961904f43cfbbee9cdb799ea5325fe8dbf25f3cc9767f2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f142b13f7d2f172e4d961904f43cfbbee9cdb799ea5325fe8dbf25f3cc9767f2?s=96&d=mm&r=g","caption":"Roland Golla"},"description":"Initiator von Never Code Alone, PHP-Trainer und Consultant f\u00fcr Softwarequalit\u00e4t rolandgolla.de - Das PHP-Training gibt es hier","sameAs":["http:\/\/www.rolandgolla.de","https:\/\/www.facebook.com\/roland.golla","https:\/\/www.linkedin.com\/in\/rolandgolla","https:\/\/x.com\/https:\/\/twitter.com\/cleancode_devel"],"url":"https:\/\/blog.nevercodealone.de\/author\/rolandgolla\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/posts\/6516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/comments?post=6516"}],"version-history":[{"count":7,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/posts\/6516\/revisions"}],"predecessor-version":[{"id":7136,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/posts\/6516\/revisions\/7136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/media\/6519"}],"wp:attachment":[{"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/media?parent=6516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/categories?post=6516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nevercodealone.de\/wp-json\/wp\/v2\/tags?post=6516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}