IT科技

當前位置 /首頁/IT科技 > /列表

parse,java

<link rel="stylesheet" href="https://js.how234.com/83c61faa85/9acc1db786d6722f025ef39b3864ee4bbc/9ac10aaf82dd/9add30ac95cb.css" type="text/css" /><link rel="stylesheet" href="https://js.how234.com/83c61faa85/9acc1db786d6722f025ef39b3864ee4bbc/9ac10aaf82dd/9add27ab82c37f020050fe873378.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><style>pre{overflow-x: auto}</style>

   <link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>

java parse是什麼,讓我們一起了解一下?

Parse是一個使用語法規則來解析輸入序列的內部DSL(在Rebol生態圈稱為“方言”)。Parse方言是TDPL家族的突出一員,常用來校驗,驗證,分解,修改輸入的數據,甚至是實現內部或者外部DSL。

Parse的規則是由哪些元素構成的?

關鍵字:Parse方言預留的單詞。

單字(word):單字所綁定的值被用於規則。

設字(word:):將單字綁定到當前的輸入流位置。

java parse

取字(:word):恢復單字綁定的輸入流位置。

整型數值:指定規則重複的數量或者範圍。

字面值:匹配輸入流中對應的字面值。

[rules]:子規則區塊。

(expression):脱離Parse方言轉而執行Red表達式,執行完畢後返回到Parse方言。

Parse的方法是如何實現的?

示例代碼如下:

const path = require("path");const url=require("url");let str="/images/fff/123/jj.jpg";console.log(path.parse(str));結果:{  root: '/',  dir: '/images/fff/123',  base: 'jj.jpg',  ext: '.jpg',  name: 'jj'}console.log(path.sep);// let u = "//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom#hash";console.log(url.parse(u));//query結果:Url {  protocol: null,  slashes: null,  auth: null,  host: null,  port: null,  hostname: null,  hash: '#hash',  search: '?id=1&name=tom',  query: 'id=1&name=tom',  pathname: '//www.how234.com:8080/images/fff/123/jj.jpg',//pathname 屬性是一個可讀可寫的字符串,可設置或返回當前 URL 的路徑部分  path: '//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom',  href: '//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom#hash'}console.log(url.parse(u,true));Url {  protocol: null,  slashes: null,  auth: null,  host: null,  port: null,  hostname: null,  hash: '#hash',  search: '?id=1&name=tom',  query: [Object: null prototype] { id: '1', name: 'tom' },//第二個參數為true,query屬性就會從查詢字符串格式(“a=1&b=2”)轉換為了對象格式({a: 1,b: 2})  pathname: '//www.how234.com:8080/images/fff/123/jj.jpg',  path: '//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom',  href: '//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom#hash'}console.log(url.parse(u,  true, true));Url {  protocol: null,  slashes: true,  auth: null,  host: 'www.how234.com:8080',//host  port: '8080',  hostname: 'www.how234.com',  hash: '#hash',  search: '?id=1&name=tom',  query: [Object: null prototype] { id: '1', name: 'tom' },  pathname: '/images/fff/123/jj.jpg',  path: '/images/fff/123/jj.jpg?id=1&name=tom',  href: '//www.how234.com:8080/images/fff/123/jj.jpg?id=1&name=tom#hash'}

TAG標籤:java parse #