-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for regexp literals and matches operator #289
Comments
I have always thought that regexps as switch-statement case-labels would be interesting. |
This comment was originally written by @seaneagan If a matches operator ( =~ ) is added, it should probably be overridable as with most other operators. The String implementation would look something like: bool operator =~ (Regexp r) => r.hasMatch(this); or maybe even allow arbitrary Patterns: bool operator =~ (Pattern p) => this.contains(p, 0); |
This comment was originally written by harmic...@gmail.com To explain the motivation a bit further:
JS - new RegExp(pattern).test(string) It is actually a bit of a nightmare to remember wether one should use The =~ operator is much easier to memorize, IMHO. Of course it does not replace the OO API, just provides some nice
But, the reality is that a lot of people writing programs in scripting
BTW, so far no one has commented on the suggestion that =~ should be My reading of the language spec is that this should not work, since main() { var date="2011-01-01"; if (match = re.firstMatch(date)) { } produces: "Matches - year is 2011", and no warnings. I guess you can get the same effect legally using: if ((match = re.firstMatch(date)) != null) { although that's not so nice to read and kind of defeats the purpose of a simple =~ operator. |
Added apr30-triage label. |
Removed apr30-triage label. |
Added triage1 label. |
We decided we will be happier keeping this at the library level (as in Java or Python). We keep the language small that way, which is a win in many ways. |
This comment was originally written by source.s...@gmail.com You are being lazy. :) Just make the language construct /^fo"o// merely translate to new RegExp(r"^foo"o/"); where RegExp is not any specific implementation. Merely have the language interprets it in context. Essentially the syntax would be pure syntactic sugar and nothing more. Surely such a simple translation from a string surrounded in /'s to a raw string isn't anything to worry about when thinking about "increasing the size of the language." It has such widespread use in other languages that there's very little reason not to have it. Also, the =~ should be in the language regardless of if we have the /foo/ syntax or not. |
This comment was originally written by beatgamm...@gmail.com Just another plug for the regex literal. I use them every day in JS, and I find it really convenient to do: if (/^fo+/.test("foobar")) Instead of the more verbose: var re = new RegExp("^fo+"); I understand the desire to keep things small, but RegExp is not something many users will care to replace with another implementation. Moving this to a library eliminates the possibility for nice syntax sugar, which I think is a fail in many ways. I am still mad that Go decided to not have the RegExp literal, and I think it's a step backward to ignore functionality that worked in JS. I was under the impression that Dart was an attempt to keep the good parts of JS (and other languages), not an attempt to make a minimal feature-set language. Please reconsider this decision. |
Issue #9983 has been merged into this issue. |
Issue #10519 has been merged into this issue. |
Issue #21697 has been merged into this issue. |
…buf, shelf, test, tools, vector_math, webdev Revisions updated by `dart tools/rev_sdk_deps.dart`. dartdoc (https://github.com/dart-lang/dartdoc/compare/59dc475..1d94484): 1d94484c 2023-05-29 dependabot[bot] Bump github/codeql-action from 2.3.3 to 2.3.5 (#3422) 0edc1a71 2023-05-28 dependabot[bot] Bump http from 0.13.6 to 1.0.0 (#3421) http (https://github.com/dart-lang/http/compare/dfec389..8a4a4a6): 8a4a4a6 2023-05-25 Brian Quinlan Add a better toString to _ClientSocketException (#948) 5c1f1ad 2023-05-25 Devon Carew regenerate with the latest mono_repo (#947) leak_tracker (https://github.com/dart-lang/leak_tracker/compare/9c6e9b3..7f2cab3): 7f2cab3 2023-05-26 Polina Cherkasova Nicely format retaining path. (#68) lints (https://github.com/dart-lang/lints/compare/72f107a..4236c43): 4236c43 2023-05-26 Parker Lougheed Remove pedantic from README (#124) 4ac79d8 2023-05-24 Parker Lougheed Update example for latest lints version (#123) mockito (https://github.com/dart-lang/mockito/compare/153c145..40fe2ca): 40fe2ca 2023-05-25 Nate Bosch Expand constraint on package:http native (https://github.com/dart-lang/native/compare/45e16dc..76bc55e): 76bc55e 2023-05-30 Daco Harkes [c_compiler] Target ios_x64 (#53) protobuf (https://github.com/dart-lang/protobuf/compare/7d2d293..346a72d): 346a72d 2023-05-30 Ömer Sinan Ağacan Fix generated ignore_for_file directives (#833) 35ea45f 2023-05-26 Kevin Moore Latest mono_repo (#834) shelf (https://github.com/dart-lang/shelf/compare/56919a1..a404b6a): a404b6a 2023-05-25 Devon Carew re-generate w/ the latest monorepo (#362) test (https://github.com/dart-lang/test/compare/309596e..3276921): 32769215 2023-05-25 dependabot[bot] Bump github/codeql-action from 2.3.2 to 2.3.5 (#2023) f74e85c8 2023-05-25 dependabot[bot] Bump dart-lang/setup-dart from 1.3.0 to 1.5.0 (#2022) 4b2bd272 2023-05-25 Devon Carew update the mono_repo and dependabot configs (#2021) tools (https://github.com/dart-lang/tools/compare/81ff996..b90a7e8): b90a7e8 2023-05-26 Devon Carew blast_repo fixes (#106) vector_math (https://github.com/google/vector_math.dart/compare/e3de8da..cd87f57): cd87f57 2023-05-30 JKris95 Axis calculation of quaternions from small angles (#272) 3762b25 2023-05-30 Lukas Klingsbo Removes the `new` keyword from readme (#284) df5877f 2023-05-30 Lukas Klingsbo Use named constructors in Vector2 and some general optimizations (#289) webdev (https://github.com/dart-lang/webdev/compare/d74fadd..4b69f1d): 4b69f1dd 2023-05-26 Anna Gringauze fix format breaking tests (#2124) b75f8e62 2023-05-25 Devon Carew re-generate w/ the latest monorepo (#2121) Change-Id: Ide9b7781102b654db15114d01cd4fbca40478906 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306304 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
…, convert, crypto, csslib, ecosystem, ffi, file, fixnum, html, http, lints, logging, markdown, matcher, mime, native, path, pool, protobuf, pub_semver, shelf, source_map_stack_trace, source_maps, source_span, sse, stack_trace, stream_channel, string_scanner, term_glyph, test_descriptor, test_process, test_reflective_loader, tools, typed_data, watcher, web_socket_channel, webdriver, webkit_inspection_protocol, yaml, yaml_edit Revisions updated by `dart tools/rev_sdk_deps.dart`. async (https://github.com/dart-lang/async/compare/def4482..9924570): 9924570 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#255) 61cdb0f 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#254) boolean_selector (https://github.com/dart-lang/boolean_selector/compare/479e1c1..7f523c3): 7f523c3 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#53) 1ed2941 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#54) browser_launcher (https://github.com/dart-lang/browser_launcher/compare/c2871b2..4f9e784): 4f9e784 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#51) 706c031 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#52) cli_util (https://github.com/dart-lang/cli_util/compare/56c1235..500dffa): 500dffa 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#91) c66e201 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#92) clock (https://github.com/dart-lang/clock/compare/200a020..f975668): f975668 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#59) eb5d2f5 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#58) convert (https://github.com/dart-lang/convert/compare/03242b2..f24afa7): f24afa7 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#89) a3e9bc5 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#90) crypto (https://github.com/dart-lang/crypto/compare/36ead7c..f3e64d2): f3e64d2 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#155) 7a7b517 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#156) csslib (https://github.com/dart-lang/csslib/compare/f6b68dd..17346e5): 17346e5 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#191) 4bdc553 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#192) ecosystem (https://github.com/dart-lang/ecosystem/compare/4acfcaf..dda7886): dda7886 2023-11-01 dependabot[bot] Bump peter-evans/create-or-update-comment (#192) b681c56 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#193) 0d768d4 2023-11-01 dependabot[bot] Bump subosito/flutter-action from 2.10.0 to 2.12.0 (#190) 178d244 2023-11-01 dependabot[bot] Bump actions/github-script (#194) 4b3e572 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#191) ffi (https://github.com/dart-lang/ffi/compare/2faec28..c926657): c926657 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#219) 3181ec0 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#220) file (https://github.com/google/file.dart/compare/7418131..e7c03aa): e7c03aa 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.6.0 (#233) fixnum (https://github.com/dart-lang/fixnum/compare/ef45eb5..3279f5d): 3279f5d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#120) 4913894 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#121) html (https://github.com/dart-lang/html/compare/49e2c8e..06bc148): 06bc148 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#232) 2630607 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#233) http (https://github.com/dart-lang/http/compare/7240d0a..b9389fe): b9389fe 2023-11-01 dependabot[bot] Bump futureware-tech/simulator-action from 2 to 3 (#1037) d7c36ae 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#1038) lints (https://github.com/dart-lang/lints/compare/5c60f48..f58fd77): f58fd77 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#168) logging (https://github.com/dart-lang/logging/compare/642ed21..324a0b5): 324a0b5 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#150) e9b13b7 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#151) markdown (https://github.com/dart-lang/markdown/compare/4e2e970..efb73b3): efb73b3 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#561) 2e4a3bc 2023-11-01 dependabot[bot] Bump subosito/flutter-action from 2.10.0 to 2.11.0 (#559) 22e378b 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#560) matcher (https://github.com/dart-lang/matcher/compare/7512f80..3d03fa1): 3d03fa1 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#231) b7d24c8 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#232) mime (https://github.com/dart-lang/mime/compare/af3e5fe..8ebf946): 8ebf946 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#108) 4328d32 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#107) native (https://github.com/dart-lang/native/compare/279094d..de9d59e): de9d59e 2023-11-01 Daco Harkes [infra] Fix PR publisher comments (#177) 22b6b24 2023-11-01 Daco Harkes [infra] Rename `dart.yaml` to `native.yaml` (#176) cc42fb1 2023-11-01 Daco Harkes [native_toolchain_c] Use sysroot on Android (#180) 01d92b0 2023-11-01 Daco Harkes [native_toolchain_c] Bump highest tested NDK version to 34 (#182) 53facde 2023-11-01 Daco Harkes [native_toolchain_c] Fix NDK discovery (#179) 285ee6c 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#174) 46a05e4 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#172) 23187fe 2023-11-01 dependabot[bot] Bump nttld/setup-ndk from 1.3.1 to 1.4.1 (#173) path (https://github.com/dart-lang/path/compare/4ca27d4..18ec71f): 18ec71f 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#153) f26c20c 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#154) pool (https://github.com/dart-lang/pool/compare/5ccef15..c78cef4): c78cef4 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#76) protobuf (https://github.com/dart-lang/protobuf/compare/3f567b2..dcec2ed): dcec2ed 2023-10-31 Ömer Sinan Ağacan Annotate deepCopy with @useResult (#897) pub_semver (https://github.com/dart-lang/pub_semver/compare/8e5a58f..f9e94ee): f9e94ee 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#95) 81fdbcf 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#94) shelf (https://github.com/dart-lang/shelf/compare/c15fc6f..b3adc7c): b3adc7c 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#391) baea52d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#392) source_map_stack_trace (https://github.com/dart-lang/source_map_stack_trace/compare/73d449c..2209626): 2209626 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#45) bfa3949 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#44) source_maps (https://github.com/dart-lang/source_maps/compare/fc6aa16..87dc587): 87dc587 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#84) 33ba11d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#85) source_span (https://github.com/dart-lang/source_span/compare/92e50bf..ed16e0d): ed16e0d 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#105) aacd748 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#104) sse (https://github.com/dart-lang/sse/compare/37df57d..8ddb95f): 8ddb95f 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#95) 8830125 2023-11-01 dependabot[bot] Bump nanasess/setup-chromedriver from 2.2.0 to 2.2.1 (#94) 86dd8f9 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#93) stack_trace (https://github.com/dart-lang/stack_trace/compare/634589f..6496ff8): 6496ff8 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#145) 3d60304 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#144) stream_channel (https://github.com/dart-lang/stream_channel/compare/ffdb208..178104d): 178104d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#98) 1193387 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#97) string_scanner (https://github.com/dart-lang/string_scanner/compare/9c525f7..a7105ef): a7105ef 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#65) f33ca6f 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#66) term_glyph (https://github.com/dart-lang/term_glyph/compare/cff80de..7c1eb9d): 7c1eb9d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#45) 39073ca 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#44) test_descriptor (https://github.com/dart-lang/test_descriptor/compare/55b5eac..c417cbb): c417cbb 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#59) dcfde39 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#58) test_process (https://github.com/dart-lang/test_process/compare/d610333..c21e40d): c21e40d 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#51) bfd0576 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#50) test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/8593eb1..17d40bb): 17d40bb 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#54) e664092 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#55) tools (https://github.com/dart-lang/tools/compare/01c0b52..dd91cb6): dd91cb6 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#192) 603b012 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#191) typed_data (https://github.com/dart-lang/typed_data/compare/d1c15ed..0b16bd2): 0b16bd2 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#76) f869102 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#77) watcher (https://github.com/dart-lang/watcher/compare/6ad58dc..b2b278a): b2b278a 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#154) 97e9637 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#155) web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/f3ac1bf..82ac73f): 82ac73f 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#289) 3615850 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#290) webdriver (https://github.com/google/webdriver.dart/compare/eaf9c58..43ed1db): 43ed1db 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#289) 02fd658 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#288) 8828360 2023-11-01 dependabot[bot] Bump nanasess/setup-chromedriver from 2.2.0 to 2.2.1 (#287) webkit_inspection_protocol (https://github.com/google/webkit_inspection_protocol.dart/compare/82f0c1c..2c6f8b6): 2c6f8b6 2023-11-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.1 (#114) d4e4d55 2023-11-01 dependabot[bot] Bump nanasess/setup-chromedriver from 2.2.0 to 2.2.1 (#115) yaml (https://github.com/dart-lang/yaml/compare/9f0d649..98a3aab): 98a3aab 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#154) b63372b 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#155) yaml_edit (https://github.com/dart-lang/yaml_edit/compare/a7e7fba..9b9d33c): 9b9d33c 2023-11-01 dependabot[bot] Bump actions/checkout from 4.1.0 to 4.1.1 (#61) b71c2e8 2023-11-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.1 to 1.6.0 (#60) Change-Id: I8b663f536d4e80728c6570372d886edfef227cf1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333059 Auto-Submit: Devon Carew <devoncarew@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Feature request for JS-like regexp literals from Mike (harmic@gmail.com) requested on misc@dartlang.org:
I really like the way I can say:
if ($date =~ /^\d+-\d+-\d+$ /) { ....
to give a trivial example. The dart alternative of:
var dateRe = const RegExp(@"^\d+-\d+-\d+$");
if (dateRe.hasMatch(date)) { ...
doesn't roll off the tongue in the same way.
So, I would like to propose two improvements.
would result in construction of a const RegExp instance, so one would
be able to say:
var dateRe = /^\d+-\d+-\d+$/;
This is not without precedent since Javascript already has such a
construct (as does Perl of course, but in a much messier way). The
flags could be 'i' for case insensitive, 'm' for multiline. It might
also be good to allow for 'x' similar to in perl, so that regex
literals can have embedded whitespace and comments - without which
some REs can be impossible to decipher.
expression
o1 =~ o2
is equivalent to:
o2.firstMatch(o1)
In addition a 'does not match' operator !~, equivalent to !
o2.hasMatch(o1)
These two combined would allow my original example to be written in
dart as:
if (date =~ /^\d+-\d+-\d+$/) { ....
This allows for the simple case of checking if something matches, but
also because =~ is equivalent to firstMatch, it will either return a
Match object or null, so one can say:
if (dateMatch = (date =~ /^(\d+)-(\d+)-(\d+)$/)) { ....
In the case of a succesful match, dateMatch will contain the result of
the match.
The text was updated successfully, but these errors were encountered: