Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 280

Questions on expression testing and manipulation through pattern matching and constructing efficient patterns.

5
votes
As Leonid explained in the comment, HoldForm is not transparent for the pattern matcher as opposed to HoldPattern: MatchQ[#, HoldForm[_]] & /@ {a, HoldForm[a]} MatchQ[#, HoldPattern[_]] & /@ {a, Hold …
answered Apr 25 '14 by Alexey Popkov
2
votes
Since the format of the date is explicitly known, you could construct your own DatePattern: dp = DigitCharacter ~~ DigitCharacter; myDatePattern = dp ~~ "/" ~~ dp ~~ "/" ~~ dp ~~ dp; someStringDate …
answered May 29 '18 by Alexey Popkov
11
votes
A solution using regular expression with Negative Lookahead (?!regex) Before the Match: string = "<hello>something WRONG</hello><hello>something else</hello><hello>WRONG</hello>"; StringCases[string …
answered Mar 28 '16 by Alexey Popkov
5
votes
text= {"This is a sample text.Just to test.To add a space after the dot.Okay."} StringReplace[text, WordBoundary ~~ "." ~~ Except[WhitespaceCharacter, WordBoundary] :> ". "] {"This is a sample t …
answered Oct 31 '18 by Alexey Popkov
6
votes
This problem can be solved very efficiently using string patterns: str = ToString[FromDigits@RealDigits[99/700, 10, 24][[1]]]; AbsoluteTiming[StringReplace[str, StartOfString ~~ pre : Shortest[D …
answered Jul 31 '16 by Alexey Popkov
0
votes
As b3m2a1 notes in comments, you can extract positions of specific dates using usual patterns, no need to convert date objects to strings: Position[dates1, DateObject[{your, date, here, ___}, ___]]
answered Dec 22 '17 by Alexey Popkov
3
votes
But Alternatives should be from definition something that is independent on arguments order. StringCases is based on the PCRE regular expression engine for which it isn't true: a regex engine al …
answered Mar 3 by Alexey Popkov
4
votes
This particular case is a good illustration of why it would be very useful to have a built-in analog of my shortInputForm function: Import["http://raw.github.com/AlexeyPopkov/shortInputForm/master/sh …
answered Mar 19 '17 by Alexey Popkov
1
vote
In your example StringCases works as expected because by default it searches the Longest substring which matches the pattern __ (by default all repeated string patterns are greedy). Apparently the who …
answered Aug 3 '14 by Alexey Popkov
4
votes
Here is my extension of the belisarius' first solution for the case of arbitrary number of elements in the sequence with matching $x$ coordinate (the sequence is still allowed to be only one): {{4, 5 …
answered Oct 2 '15 by Alexey Popkov
13
votes
1answer
In a comment to related question Oleksandr R. made an interesting remark: ... because string patterns are converted into regular expressions and matched using PCRE, they are subject to some stra …
asked Sep 2 '16 by Alexey Popkov
5
votes
I don't think that StringMatchQ["x", Except[{"*"}]] works as expected as well as StringMatchQ["x", Except["*"]]: StringMatchQ["x", Except[{"*"}]] StringMatchQ["x", Except["*"]] True True The s …
answered Jun 14 '16 by Alexey Popkov
1
vote
You can directly set a list of replacement rules as Downvalues of your Symbol in the order you prefer: DownValues[nonCommute] = {HoldPattern@nonCommute[left___, x_, x_, right___] :> f0[(*...* …
answered Nov 2 '14 by Alexey Popkov
3
votes
Two examples are given under the "Implementation Details" section of the official tutorial "Working with String Patterns" (thanks to WReach for the pointer): Because PCRE currently does not suppor …
answered Mar 21 '17 by Alexey Popkov
4
votes
For your second question How can I select from a list of integers those that have a difference with their neighbor ( left or right, or both) unity? you could use: lst = RandomInteger[10, 10] Fl …
answered Aug 9 '15 by Alexey Popkov

15 30 50 per page