How to eregi_replace to preg_replace [duplicate] - preg-replace

This question already has answers here:
How can I convert ereg expressions to preg in PHP?
(4 answers)
Closed 8 years ago.
eregi_replace('[0-9]+\.+[0-9]','',$cart['unit']);
How to change it to preg_replace?
I get an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier '+' in ---

You can use your existing Regex almost unchanged in a preg_replace(). Just add delimiters and a case-insensitive modifier. You get
preg_replace('#[0-9]+\.+[0-9]#i','',$cart['unit']);
In fact, the case-sensitivity is irrelevant since your pattern only matches 0-9 and .

Related

VSCode: Incremented numbers at each cursor [duplicate]

This question already has answers here:
How to replace a string pattern with increasing integers using regex
(2 answers)
Closed 1 year ago.
When you create multiple cursors in VSCode, how can you type a number at each cursor such that each number is 1 greater than the previous number, starting at 0?
You can use the extension Regex Text Generator
For match expression use: .*
For generator expression use: {{=i}}

I would like to use a dollar sign in a flutter, how can I do this? [duplicate]

This question already has answers here:
Special characters in Flutter
(6 answers)
Closed 2 years ago.
I would like to use a dollar sign in a flutter, how can I do this?
like this:
Text('$21.99')
Use Escape Sequence Character,
Text('\$21.99')
You can use raw string by suffixing r.
Like this
Text(r'$21.99')

Regex to prevent repeated characters or numbers [duplicate]

This question already has answers here:
Regular Expression To Match String Not Starting With Or Ending With Spaces
(2 answers)
Regex for password: repetitive characters
(4 answers)
Closed 4 years ago.
static let password = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$"
I have this regex to validate password
at least one character
at least one Capital character
at least one number
length more than 8
I need to update it to
prevent any repeated sequence of characters or numbers
to prevent "111111" or "aaaaaaa" for example
to prevent starting and ending with space character
how to update my regex to match those requirements ?

Swift 4 regex custom validation [duplicate]

This question already has an answer here:
Learning Regular Expressions [closed]
(1 answer)
Closed 4 years ago.
i need some help to write correct regex validation. I want password with no spaces, min. 6 symbols, doesn't matter numbers or letters or symbols. Alphabet a-zA-Z and а-яА-Я(RU). How i can do that?
"^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{6,}$"
You can take a look at this link

See what characters are in an NSCharacterSet [duplicate]

This question already has answers here:
NSArray from NSCharacterSet
(9 answers)
Closed 7 years ago.
When I'm trying
print(NSCharacterSet.URLQueryAllowedCharacterSet())
it prints
<__NSCFCharacterSet: 0x1759b900>
How do I make it more informative?
You can get a representation of the character set using bitmapRepresentation which could be queried. Or you could do basically the same thing with a loop over all characters and using characterIsMember:. The output is potentially big...
There isn't really a simple option or a generic concise output to what you're asking for. It isn't a common requirement.