repeat

How do I match a pattern with optional surrounding quotes?

好久不见. 提交于 2019-11-30 11:44:55
How would one write a regex that matches a pattern that can contain quotes, but if it does, must have matching quotes at the beginning and end? "?(pattern)"? Will not work because it will allow patterns that begin with a quote but don't end with one. "(pattern)"|(pattern) Will work, but is repetitive. Is there a better way to do that without repeating the pattern? You can get a solution without repeating by making use of backreferences and conditionals : /^(")?(pattern)(?(1)\1|)$/ Matches: pattern "pattern" Doesn't match: "pattern pattern" This pattern is somewhat complex, however. It first

REGEX - Matching any character which repeats n times

我与影子孤独终老i 提交于 2019-11-30 11:28:25
How to match any character which repeats n times? Example: for input: abcdbcdcdd for n=1: .......... for n=2: ......... for n=3: .. ..... for n=4: . . .. for n=5: no matches After several hours my best is this expression (\w)(?=(?:.*\1){n-1,}) //where n is variable which uses lookahead. However the problem with this expression is this: for input: abcdbcdcdd for n=1 .......... for n=2 ... .. . for n=3 .. . for n=4 . for n=5 no matches As you can see, when lookahead matches for a character, let's look for n=4 line, d 's lookahead assertion satisfied and first d matched by regex. But remaining d

Bitmap repeat + rounded corners

蓝咒 提交于 2019-11-30 09:00:42
问题 I am trying to create rectangle with rounded corners and background as repeated bitmaps. I am writing like this, but getting bitmaps in the corners. Could anyone help out? background.xml <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape> <stroke android:width="1dp" android:color="#FFFFFF" /> <corners android:radius="50dp" /> </shape> </item> <item> <bitmap android:src="@drawable/carbon_4" android:tileMode="repeat" /> <

repeatedly applying a function until the result is stable

本秂侑毒 提交于 2019-11-30 08:02:52
I want to repeatedly apply a function simplify' until the result is "stable" (i.e. simplify'(x) == x ): simplify :: Expr -> Expr simplify expr = let iterations = iterate simplify' expr neighbours = zip iterations (tail iterations) simplified = takeWhile (\(a, b) -> a /= b) neighbours in snd $ last ((expr, expr) : simplified) simplify' :: Expr -> Expr This seems to be a common problem to me. Is there a more elegant solution? Update: I found a much simpler solution, but I'm still looking for a more elegant solution :) simplify expr = let next = simplify' expr in if next == expr then expr else

Is it possible to override the keydown repeat delay, in JavaScript?

北城以北 提交于 2019-11-30 06:59:58
问题 The objective is manually set a held key's "repeat rate". For example, when in a text box and pressing and holding the X key, I understand that there is browser-specific ways of repeating the pressed character. In some, it pauses, then continuously triggers the pressed key. In others, it doesn't repeat at all. I want to mitigate this by forcing the pressed key to repeat at a specific interval, regardless of browser. Through research, I've come up with a timer-based attempt, but in Safari, it

How can I repeat a string N times in Perl?

别等时光非礼了梦想. 提交于 2019-11-30 05:34:12
In Python, if I do this: print "4" * 4 I get > "4444" In Perl, I'd get > 16 Is there an easy way to do the former in Perl? Vinko Vrsalovic $ perl -e 'print "4"x4; print "\n"' 4444 The x operator is documented in perldoc perlop . Here binary means an operator taking two arguments, not composed of bits, by the way. Binary "x" is the repetition operator. In scalar context or if the left operand is not enclosed in parentheses, it returns a string consisting of the left operand repeated the number of times specified by the right operand. In list context, if the left operand is enclosed in

Repeat animation angular 4

醉酒当歌 提交于 2019-11-30 04:42:31
问题 I created the following animation: fade.animation.ts: import { Component } from '@angular/core'; import { trigger, state, animate, query, transition, style, stagger } from '@angular/animations'; export let fade = trigger('fade', [ state('void', style({ opacity: 0 })), transition(':enter, :leave', [ animate(2000) ]) ]); I'm using in the next component: <div id="mpl_loader" class="divCabeceraTitulo"> <div class="lineaTitulo"> <div class="logoMinisterio" [@fade]> <img src="assets/imagenes

CSS: Repeat Table Header after Page Break (Print View)

大兔子大兔子 提交于 2019-11-30 01:57:06
问题 I have html table for printing with repeat header and footer. Everything works, document to break automatically. But now i would like to break page after any element. I use to css property page-break-after and set it to always. Yes, its works, but i got another problem. Page after break dont repeat header and footer of table. What is wrong? Browsers: IE8. Print styles: table thead {display: table-header-group;} table tfoot { display: table-footer-group;} table tbody { display: table-row-group

gem ice_cube for reccurence events

岁酱吖の 提交于 2019-11-29 21:04:19
问题 I have simple Event model (title, date, user) And I created Events Calendar by months (gem 'watu_table_builder'). I need the feature to create repeating events. I figured out that I may use gem ice_cube for it. But it is not clear for me. I added to model: class Event < ActiveRecord::Base #require 'ice_cube' include IceCube belongs_to :user validates :title, :presence => true, :length => { :minimum => 5 } validates :shedule, :presence => true def self.events_and_repeats(date) @events = Event

Get duplicate characters in string

淺唱寂寞╮ 提交于 2019-11-29 17:46:26
I try to match/get all repetitions in a string. This is what I've done so far: var str = 'abcabc123123'; var REPEATED_CHARS_REGEX = /(.).*\1/gi; console.log( str.match(REPEATED_CHARS_REGEX) ); // => ['abca', '1231'] As you can see the matching result is ['abca', '1231'] , but I excpect to get ['abc', '123'] . Any ideas to accomplish that? 2nd question: Another thing I excpect, is to make it possible to change the duration how often a char needs to be in the string to get matched... For example if the string is abcabcabc and the repetation-time is set to 2 it should result in ['abcabc'] . If