Repository: nitely/nim-regex Branch: master Commit: 2c41f0b2fee9 Files: 34 Total size: 6.4 MB Directory structure: gitextract_tvdvmii5/ ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── bench/ │ ├── README.md │ ├── bench.nim │ └── input-text.txt ├── docs/ │ ├── index.html │ └── regex/ │ └── .keep ├── regex.nimble ├── src/ │ ├── regex/ │ │ ├── common.nim │ │ ├── compiler.nim │ │ ├── dotgraph.nim │ │ ├── exptransformation.nim │ │ ├── exptype.nim │ │ ├── litopt.nim │ │ ├── nfa.nim │ │ ├── nfafindall.nim │ │ ├── nfafindall2.nim │ │ ├── nfamacro.nim │ │ ├── nfamatch.nim │ │ ├── nfamatch2.nim │ │ ├── nfatype.nim │ │ ├── nodematch.nim │ │ ├── oldregex.nim │ │ ├── parser.nim │ │ ├── scanner.nim │ │ └── types.nim │ └── regex.nim └── tests/ ├── tests.nim ├── tests2.nim └── tests_misc.nim ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: nitely_ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry polar: # Replace with a single Polar username buy_me_a_coffee: # Replace with a single Buy Me a Coffee username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: push: branches: - master pull_request: jobs: test: name: Nim ${{ matrix.nim }} runs-on: ubuntu-latest strategy: matrix: nim: [1.6.20, 2.0.14, 2.2.0] steps: - uses: actions/checkout@v2 - name: Run Tests run: | docker pull nimlang/nim:${{ matrix.nim }} docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app nimlang/nim:${{ matrix.nim }} /bin/bash -c "git config --global --add safe.directory /usr/src/app; nimble install -y; nimble test" - name: Build docs if: matrix.nim == '1.6.20' run: | docker pull nimlang/nim:${{ matrix.nim }} docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app nimlang/nim:${{ matrix.nim }} /bin/bash -c "git config --global --add safe.directory /usr/src/app; nimble install -y; nimble docs" - name: Deploy docs # to view docs on your own fork: push a gh-pages branch on your fork, # enable gh-pages in your fork # and remove `github.ref == 'refs/heads/master'` below if: | github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.nim == '1.6.20' uses: crazy-max/ghaction-github-pages@v1 with: build_dir: docs target_branch: gh-pages env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ================================================ FILE: .gitignore ================================================ nimcache/ src/regex.js src/regex.out src/regex/litopt src/regex/nfatype src/regex/common tests/tests tests/tests.js tests/tests2 tests/tests2.js tests/tests_misc tests/tests_misc.js tests/test_bug docs/ugh bin/* bench/bench config.nims ================================================ FILE: CHANGELOG.md ================================================ v0.26.2 ================== * Performance improvements v0.26.1 ================== * Fix unicode case-insensitive match edge case #150 v0.26.0 ================== * Performance improvements * Fix devel compiler warnings v0.25.0 ================== * Drop support for Nim < 1.6 * Implement PCRE var flags (#137) * Performance improvements v0.24.1 ================== * Disable utf8 regex check for arbitrary bytes (#136) v0.24.0 ================== * Fix dot to match anything in ascii mode (#135) * Match arbitrary bytes (#134) v0.23.0 ================== * Verify input is utf-8 (#131) v0.22.0 ================== * Literals substring optimization (#130) * Refactor epsilon transitions (#129) v0.21.0 ================== * Deprecated all of the APIs (except the macro one) * New API (issue #111) * Removed the "capture all group/submatch repetitions" feature. Only the last group repetition is captured. Changes to migrate to the new API: ```text re"regex" -> re2"regex" Regex -> Regex2 RegexMatch -> RegexMatch2 ``` Then deal with `group(RegexMatch2, int)` and similar APIs returning the last capture group/submatch repetition instead of a sequence with all of them. v0.20.2 ================== * Nim compat fixes: #119 v0.20.1 ================== * Nim compat fixes: #117 v0.20.0 ================== * Add `reRepRangeLimit` compile option to define range limit #113 * Nim compat fixes: #98, #101, #110 v0.19.0 ================== * Adds support for unbounded lookaround assertions * Fix: parsing `{n,m}` repetitions is less strict; `{}`, `{abc}`, etc are parsed as characters. This is closer to PCRE, but it won't allow error prone instances such as missing brackets: `{123`. * Fix: double repetitions: `**`, `++`, `*+`, `???`, `{n}*`, `{n}+`, and other combinations are no longer allowed. The `++` PCRE hack is not allowed, as it won't work the same way anyway. v0.18.0 ================== * Adds `escapeRe(string): string` function * Removed `unicodeplus` dependency v0.17.1 ================== * Fix: regression related to repetitions, and lonely assertions; issue #83 * Fix: make it compile with ARC; thanks to @timotheecour v0.17.0 ================== * Removes macro usage for regular function APIs * Adds `match` block macro * Fix: sub-matches with nested optional operators (ex: `(a?)*`) to work the same as PCRE v0.16.2 ================== * Adds `findAllBounds` * Adds some minor perf improvements v0.16.1 ================== * Adds `groupFirstCapture`, `groupLastCapture`, and `group(1): seq[string]` for group numbers * Adds support for negative lookaround assertions v0.16.0 ================== * Adds literals optimization to `findAll`, `split`, `splitIncl`, and `replace`; this makes some regexes run ~100x faster. * Support lookbehind; this is limited to one character * Fix: `findAll` ran in quadratic time for some regexes; `split`, `splitIncl`, and `replace` were also affected; Linear time is now guaranteed. * Fix: regex compilation errors were swallow due to a Nim bug; A workaround to raise the error was implemented v0.15.0 ================== * Fix multiline not working with beginning of line, issue #13 * Fix replace re"", issue #29 * Fixes a number of issues related to empty matches in the `findAll`, `split`, and `replace` APIs v0.14.1 ================== * Fix non-greedy find, issue #61 (v0.14.0 regression) v0.14 ================== * Drop Nim 0.19.0 support (0.19.6 is supported) * Changed all `proc` to `func` * Faster macro for static regex * Deprecated `toPattern` * New `match` API that does not require the `MatchRegex` parameter v0.13.1 ================== * Fix nested non-capturing group repetition #46 * Remove stylecheck config #55 v0.13 ================== * Add `groupFirstCapture`, `groupLastCapture`, and `group(1): seq[string]` (thanks to @xmonader) * Add Nim 1.0.0 to CI * Drop Nim 0.18 support * Fix nested captures with repetition range; issue #46 * Fix Nim `sets` warnings v0.12 ================== * Support matching at compile-time; issue #4 (thanks to @timotheecour) v0.11.2 ================== * Added `isInitialized*(re: Regex)` v0.11.1 ================== * Fix `\w` not matching `_` on ASCII mode * Fixes to support the JS backend v0.11 ================== * Update to Unicode 12.1 v0.10.1 ================== * Fix for Nim devel (PR #34) v0.10.0 ================== * Add Nim 0.18 support back v0.9.0 (unreleased) ================== * Drop Nim 0.18 support * Improved `re` API to support compile-time or run-time compilation depending on input (thanks to @timotheecour) v0.8.0 ================== * Drop Nim 0.17 support * Add Nim 0.19 support * Update dependencies * Remove deprecated `match` and `find` returning `Option[RegexMatch]` v0.7.4 ================== * Add `splitIncl`, similar to `split` but includes captured groups v0.7.3 ================== * Fix deprecation warnings on devel v0.7.2 ================== * Fixes for devel (#17) v0.7.1 ================== * Update dependencies v0.7.0 ================== * New API taking `var RegexMatch` instead of returning `Option[RegexMatch]` * Deprecate `match` and `find` returning `Option[RegexMatch]` * Update to unicode 11 v0.6.3 ================== * Pretty error messages v0.6.2 ================== * Adds limited lookahead support * Improves compilation time v0.6.1 ================== * Initial release ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2017 Esteban Castro Borsani Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Regex [](https://github.com/nitely/nim-regex/actions?query=workflow%3ACI) [](https://raw.githubusercontent.com/nitely/nim-regex/master/LICENSE) A library for parsing, compiling, and executing regular expressions at both runtime and compile-time. Features: * The match time is linear in the length of the input string * Supports compiling regex at compile-time * Supports matching at compile-time * Unicode level-1 support * Descriptive error messages * PCRE syntax and semantics ## Install ``` nimble install regex ``` # Compatibility Nim +1.6.0 ## Docs [Read the docs](https://nitely.github.io/nim-regex/) ## Tests ``` nimble test ``` ## Debugging Compile with `-d:regexDotDir:.` to generate [dot files](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) of the regexes (NFAs) within the nim file. A dot file can be viewed in [Graphviz](https://dreampuf.github.io/GraphvizOnline/). Requires Nim +1.2. ## LICENSE MIT ================================================ FILE: bench/README.md ================================================ ## Benchmarks Run first: ``` nimble install nimbench nimble develop ``` Run benchmarks: ``` nim c -r -d:danger bench/bench.nim ``` ================================================ FILE: bench/bench.nim ================================================ import pkg/nimbench import std/unicode from std/re import nil from ../src/regex import nil func genText(): string {.compileTime.} = result = "" for _ in 0 .. 100000: result.add("a") result.add("sol") for _ in 0 .. 100000: result.add("b") #result.add("ฅ") const text = genText() var pattern2 = re.re"^\w*sol\w*$" bench(re_sol, m): var d: bool for i in 0 ..< m: d = re.match(text, pattern2) doNotOptimizeAway(d) const pattern4 = regex.re2(r"\w*sol\w*") #, {regex.RegexFlag.reAscii}) benchRelative(regex_sol, m): var m2: regex.RegexMatch2 for i in 0 ..< m: discard regex.match(text, pattern4, m2) doNotOptimizeAway(m2) benchRelative(regex_macro_sol, m): var d: bool for i in 0 ..< m: regex.match text, regex.rex"\w*sol\w*": d = true doNotOptimizeAway(d) var dummyTextNums = """650-253-0001""" var pattern_nums = re.re"^[0-9]+-[0-9]+-[0-9]+$" bench(re_nums, m): var d: bool for i in 0 ..< m: d = re.match(dummyTextNums, pattern_nums) doNotOptimizeAway(d) const n_pattern_nums = regex.re2"[0-9]+-[0-9]+-[0-9]+" benchRelative(regex_nums, m): var m2: regex.RegexMatch2 for i in 0 ..< m: discard regex.match(dummyTextNums, n_pattern_nums, m2) doNotOptimizeAway(m2) benchRelative(regex_macro_nums, m): var d: bool for i in 0 ..< m: regex.match text, regex.rex"[0-9]+-[0-9]+-[0-9]+": d = true doNotOptimizeAway(d) var pattern_nums2 = re.re"^[0-9]+..*$" bench(re_nums2, m): var d: bool for i in 0 ..< m: d = re.match(dummyTextNums, pattern_nums2) doNotOptimizeAway(d) const n_pattern_nums2 = regex.re2"[0-9]+..*" benchRelative(regex_nums2, m): var m3: regex.RegexMatch2 for i in 0 ..< m: discard regex.match(dummyTextNums, n_pattern_nums2, m3) doNotOptimizeAway(m3) benchRelative(regex_macro_nums2, m): var d: bool for i in 0 ..< m: regex.match text, regex.rex"[0-9]+..*": d = true doNotOptimizeAway(d) when false: # XXX remove var lits_find_re = re.re"do|re|mi|fa|sol" bench(re_lits_find, m): var d: int for i in 0 ..< m: d = re.find(text, lits_find_re) doNotOptimizeAway(d) const lits_find = regex.re2"do|re|mi|fa|sol" benchRelative(regex_lits_find, m): var m2: regex.RegexMatch2 for i in 0 ..< m: discard regex.find(text, lits_find, m2) doNotOptimizeAway(m2) const bench_text = staticRead("input-text.txt") var email_find_all_re = re.re"[\w\.+-]+@[\w\.-]+\.[\w\.-]+" bench(re_email_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, email_find_all_re): d += 1 doAssert d == 92 doNotOptimizeAway(d) const email_find_all = regex.re2"[\w\.+-]+@[\w\.-]+\.[\w\.-]+" benchRelative(regex_email_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, email_find_all): d += 1 doAssert d == 92 doNotOptimizeAway(d) var uri_find_all_re = re.re"[\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" bench(re_uri_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, uri_find_all_re): d += 1 doAssert d == 5301 doNotOptimizeAway(d) const uri_find_all = regex.re2"[\w]+://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" benchRelative(regex_uri_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, uri_find_all): d += 1 doAssert d == 5301 doNotOptimizeAway(d) var ip_find_all_re = re.re"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])" bench(re_ip_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, ip_find_all_re): d += 1 doAssert d == 5 doNotOptimizeAway(d) const ip_find_all = regex.re2"(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])" benchRelative(regex_ip_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, ip_find_all): d += 1 doAssert d == 5 doNotOptimizeAway(d) var sql_find_all_re = re.re"mysql://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" bench(re_sql_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, sql_find_all_re): d += 1 doAssert d == 4 doNotOptimizeAway(d) const sql_find_all = regex.re2"mysql://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" benchRelative(regex_sql_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, sql_find_all): d += 1 doAssert d == 4 doNotOptimizeAway(d) var url_find_all_re = re.re"https?://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" bench(re_url_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, url_find_all_re): d += 1 doAssert d == 5295 doNotOptimizeAway(d) const url_find_all = regex.re2"https?://[^/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?" benchRelative(regex_url_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, url_find_all): d += 1 doAssert d == 5295 doNotOptimizeAway(d) var unicode_find_all_re = re.re"\smůžete\s" bench(re_unicode_find_all, m): var d = 0 for i in 0 ..< m: for _ in re.findAll(bench_text, unicode_find_all_re): d += 1 doAssert d == 25 doNotOptimizeAway(d) const unicode_find_all = regex.re2"\smůžete\s" benchRelative(regex_unicode_find_all, m): var d = 0 for i in 0 ..< m: for _ in regex.findAll(bench_text, unicode_find_all): d += 1 doAssert d == 25 doNotOptimizeAway(d) when true: bench(runes, m): var d = 0 for i in 0 ..< m: for _ in bench_text.runes: d += 1 doNotOptimizeAway(d) bench(dummy, m): for i in 0 ..< m: memoryClobber() when isMainModule: runBenchmarks() #[ # Profiling: # (but extract the bench to another module without nimbench) # open the log with KCachegrind $ nim c --debugger:native --threads:off -d:danger -d:useMalloc -o:bin/bench2 bench/bench2.nim && valgrind --tool=callgrind -v ./bin/bench2 # Bench $ nim c -r --threads:off -d:danger --mm:arc -o:bin/bench bench/bench.nim ]# ================================================ FILE: bench/input-text.txt ================================================ This file is a concatenation of [Learn X in Y minutes](https://github.com/adambard/learnxinyminutes-docs) for testing purposes. It is published under the original project license ([Creative Commons Attribution-ShareAlike 3.0 Unported](http://creativecommons.org/licenses/by-sa/3.0/deed.en_US)). ------ category: tool tool: amd contributors: - ["Frederik Ring", "https://github.com/m90"] filename: learnamd.js --- ## Getting Started with AMD The **Asynchronous Module Definition** API specifies a mechanism for defining JavaScript modules such that the module and its dependencies can be asynchronously loaded. This is particularly well suited for the browser environment where synchronous loading of modules incurs performance, usability, debugging, and cross-domain access problems. ### Basic concept ```javascript // The basic AMD API consists of nothing but two methods: `define` and `require` // and is all about module definition and consumption: // `define(id?, dependencies?, factory)` defines a module // `require(dependencies, callback)` imports a set of dependencies and // consumes them in the passed callback // Let's start by using define to define a new named module // that has no dependencies. We'll do so by passing a name // and a factory function to define: define('awesomeAMD', function(){ var isAMDAwesome = function(){ return true; }; // The return value of a module's factory function is // what other modules or require calls will receive when // requiring our `awesomeAMD` module. // The exported value can be anything, (constructor) functions, // objects, primitives, even undefined (although that won't help too much). return isAMDAwesome; }); // Now, let's define another module that depends upon our `awesomeAMD` module. // Notice that there's an additional argument defining our // module's dependencies now: define('loudmouth', ['awesomeAMD'], function(awesomeAMD){ // dependencies will be passed to the factory's arguments // in the order they are specified var tellEveryone = function(){ if (awesomeAMD()){ alert('This is sOoOo rad!'); } else { alert('Pretty dull, isn\'t it?'); } }; return tellEveryone; }); // As we do know how to use define now, let's use `require` to // kick off our program. `require`'s signature is `(arrayOfDependencies, callback)`. require(['loudmouth'], function(loudmouth){ loudmouth(); }); // To make this tutorial run code, let's implement a very basic // (non-asynchronous) version of AMD right here on the spot: function define(name, deps, factory){ // notice how modules without dependencies are handled define[name] = require(factory ? deps : [], factory || deps); } function require(deps, callback){ var args = []; // first let's retrieve all the dependencies needed // by the require call for (var i = 0; i < deps.length; i++){ args[i] = define[deps[i]]; } // satisfy all the callback's dependencies return callback.apply(null, args); } // you can see this code in action here: http://jsfiddle.net/qap949pd/ ``` ### Real-world usage with require.js In contrast to the introductory example, `require.js` (the most popular AMD library) actually implements the **A** in **AMD**, enabling you to load modules and their dependencies asynchronously via XHR: ```javascript /* file: app/main.js */ require(['modules/someClass'], function(SomeClass){ // the callback is deferred until the dependency is loaded var thing = new SomeClass(); }); console.log('So here we are, waiting!'); // this will run first ``` By convention, you usually store one module in one file. `require.js` can resolve module names based on file paths, so you don't have to name your modules, but can simply reference them using their location. In the example `someClass` is assumed to be in the `modules` folder, relative to your configuration's `baseUrl`: * app/ * main.js * modules/ * someClass.js * someHelpers.js * ... * daos/ * things.js * ... This means we can define `someClass` without specifying a module id: ```javascript /* file: app/modules/someClass.js */ define(['daos/things', 'modules/someHelpers'], function(thingsDao, helpers){ // module definition, of course, will also happen asynchronously function SomeClass(){ this.method = function(){/**/}; // ... } return SomeClass; }); ``` To alter the default path mapping behavior use `requirejs.config(configObj)` in your `main.js`: ```javascript /* file: main.js */ requirejs.config({ baseUrl : 'app', paths : { // you can also load modules from other locations jquery : '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min', coolLibFromBower : '../bower_components/cool-lib/coollib' } }); require(['jquery', 'coolLibFromBower', 'modules/someHelpers'], function($, coolLib, helpers){ // a `main` file needs to call require at least once, // otherwise no code will ever run coolLib.doFancyStuffWith(helpers.transform($('#foo'))); }); ``` `require.js`-based apps will usually have a single entry point (`main.js`) that is passed to the `require.js` script tag as a data-attribute. It will be automatically loaded and executed on pageload: ```html
Name:
element to the application variable name.
*/
My first expression: {{ 5 + 5 }}
My first expression: {{ 5 + 5 }}
Name:
{{name}}
Total in dollar: {{ quantity * cost }}
The name is
The name is {{ person.lastName }}
The third result is {{ points[2] }}
Name:
You wrote: {{ firstName }}
The name is {{ lastName | uppercase }}
The name is {{ lastName | lowercase }}
Total = {{ (quantity * price) | currency }}
| {{ x.Name }} | {{ x.Country }} |
| {{ x.Name }} | {{ x.Country }} |
| {{ $index + 1 }} | {{ x.Name }} | {{ x.Country }} |
| {{ x.Name }} | {{ x.Name }} | {{ x.Country }} | {{ x.Country }} |
Button
// If the value of mySwitch evaluates to false, the button will not be disabled:
// The ng-show directive shows or hides an HTML element.
I am visible.
I am not visible.
I am visible.
{{ count }}
First Name:
Last Name:
Full Name: {{firstName + " " + lastName}}
element with two input fields, // according to the value (true or false) of myVar. // The function toggle() toggles myVar between true and false. // The value ng-hide="true" makes the element invisible. // The ng-show directive can also be used to set the visibility of a part of an application. // The value ng-show="false" makes an HTML element invisible. // The value ng-show="true" makes the element visible. // Here is the same example as above, using ng-show instead of ng-hide:
First Name:
Last Name:
Full Name: {{firstName + " " + lastName}}
هذه فقرة.
هذه فقرة أخرى.
هذه فقرة.
هذه فقرة أخرى.
| العنوان الأول | العنوان الثاني |
|---|---|
| الصف الأول، العمود الأول | الصف الأول، العمود الثاني |
| الصف الثاني، العمود الأول | الصف الثاني، العمود الأول |
Set myVariable to "myValue"
Set myNumber to 3.14
Display myVariable:
Display myNumber:
Set myArray1 to an array of 1 dimension using literal or bracket notation
Set myArray2 to an array of 1 dimension using function notation
Contents of myArray1
Contents of myArray2
1 + 1 =
10 - 7 =
15 * 10 =
100 / 5 =
120 % 5 =
120 mod 5 =
Is 1 eq 1?
Is 15 neq 1?
Is 10 gt 8?
Is 1 lt 2?
Is 10 gte 5?
Is 1 lte 5?
Is 1 == 1?
Is 15 != 1?
Is 10 > 8?
Is 1 < 2?
Is 10 >= 5?
Is 1 <= 5?
Condition to test for: "
Index equals
Set myArray3 to [5, 15, 99, 45, 100]
Index equals
Set myArray4 to ["Alpha", "Bravo", "Charlie", "Delta", "Echo"]
Index equals
Set myArray5 to [5, 15, 99, 45, 100]
| Value | As Boolean | As number | As date-time | As string |
|---|---|---|---|---|
| "Yes" | TRUE | 1 | Error | "Yes" |
| "No" | FALSE | 0 | Error | "No" |
| TRUE | TRUE | 1 | Error | "Yes" |
| FALSE | FALSE | 0 | Error | "No" |
| Number | True if Number is not 0; False otherwise. | Number | See "Date-time values" earlier in this chapter. | String representation of the number (for example, "8"). |
| String | If "Yes", True If "No", False If it can be converted to 0, False If it can be converted to any other number, True |
If it represents a number (for example, "1,000" or "12.36E-12"), it is converted to the corresponding number. | If it represents a date-time (see next column), it is converted to the numeric value of the corresponding date-time object. If it is an ODBC date, time, or timestamp (for example "{ts '2001-06-14 11:30:13'}", or if it is expressed in a standard U.S. date or time format, including the use of full or abbreviated month names, it is converted to the corresponding date-time value. Days of the week or unusual punctuation result in an error. Dashes, forward-slashes, and spaces are generally allowed. |
String |
| Date | Error | The numeric value of the date-time object. | Date | An ODBC timestamp. |
#sayHello()#
#getHello()#
#getWorld()#
#setHello("Hola")#
#setWorld("mundo")#
#sayHello()#
#getHello()#
#getWorld()#