I have a simple regular expression:
[0-9]{1,5}x[0-9]{1,5}
Which is designed to detect the width and height of an image from a
string, as in:
foo 100x100 bar
However, when I run this with preg_match I get an unknown modifier
error, pointing to { . Could someone please explain what I am doing
wrong and how to make this work.
preg_match("[0-9]{1,5}x[0-9]{1,5}", $output, $widthHeight);
$output is the string containing the width height values
$widthHeight is the returning array.
Many thanks.
P.s. Maximum image size is 99999x99999 2 1833
On Tue, 2006-03-21 at 20:39 +0000, splodge wrote: I have a simple regular expression:
[0-9]{1,5}x[0-9]{1,5}
Which is designed to detect the width and height of an image from a string, as in:
foo 100x100 bar
However, when I run this with preg_match I get an unknown modifier error, pointing to { . Could someone please explain what I am doing wrong and how to make this work.
preg_match("[0-9]{1,5}x[0-9]{1,5}", $output, $widthHeight);
$output is the string containing the width height values $widthHeight is the returning array. Many thanks.
P.s. Maximum image size is 99999x99999
Try enclosing your expression with / /.
preg_match("/[0-9]{1,5}x[0-9]{1,5}/", $output, $widthHeight);
what about the case where an image size starts with 0 (i.e. 0999x0111)
which can cause wackiness since the number will be converted to octal.
Maybe this? p.s. \d == [0-9]
preg_match("[1-9]\d{0,4}x[1-9]\d{0,4}", $output, $widthHeight); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Linders |
last post by:
Hi,
I'm trying to figure out the most efficient method for taking the
first character in a string (which will be a number), and use
it as a variable to check to see if the other numbers in the string
match that first number. I'm using this code for form validation of a
telephone number.
Previous records from the past few months show that when someone is
just messing around on one of our forms (to waste our time), they type
|
by: Moluske |
last post by:
The web site was on another server i switch to a new one but this server hav
now PHP Safe Mode to ON so i get error when creating thumbnail. I cant put
PHP Safe mode to OFF. is ther any thing i can do so it will be able to
create the thumbnail again ?
site: www.jfl-media.com
Thanks
J-F
her is the script:
|
by: TekWiz |
last post by:
I'm using regex to validate data, but preg_match gives the Warning
"Unknown modifier '\' " when I have '\\' in the regular expression.
Is this a problem with preg_match() or do I have to do something
different with regex?
Note: I ran my expression through "The Regex Coach" by Dr. Weitz and it
worked properly.
--TekWiz
|
by: Stefan Reiter |
last post by:
Hi,
I need one function to validate streetnames and one to validate names.
I tried to write my own regular expression and to use preg_match,
but for some weird reason I can't get it to work.
Valid names should be:
Peter
Christian-Peter
Li
|
by: Paul |
last post by:
Hi,
Does anyone know if it's possible to use regular expressions to grab
all content between two words. For example....
------
This is some example text to illustrate my problem and here's another
my for you.
------
| |
by: Clodoaldo Pinto |
last post by:
preg_match(): Compilation failed: regular expression too large at
offset 0
The regular expression is 34,745 bytes long.
<?php
$regExp = 'huge regexp with 34,745 bytes';
echo '<pre>strlen($regExp) = ', strlen($regExp), "\n";
echo preg_match($regExp, 'sudokusweb.com');
echo '</pre>';
|
by: Buglish |
last post by:
Hi,
Task :
-Capture a HTML table with use of regular expression from a text string buffer(entire document).
–Pass it to another function to create a multi dimension array out of it.
- Pass it to another function to build it into a RTF table.
-Then return it back to the regular expression to replace the search result.
Difficulty:
-The regular expression doesn’t pass the back referenced table fields to the next function.
|
by: jgentes |
last post by:
Hey, I am attempting to create a random password string, and I am getting a timeout error on the regular expression. its giving me errors on the checks. line 25/27/29/31
function gen_secure($rand_len = false)
{
$config = array(
0 => "EXDHKFRLACYZJSWMPVGBNUT",
1 => "jhwzqbgkmadovrsnxyftpicue",
2 => "47358926",
3 => "`~!@#$^&*()_-+=\\}]{);
|
by: Happy Face |
last post by:
Hi, All,
I encountered this strange problem while using function preg_match.
The following is the php code.
when I set the line:
$text = str_repeat('*', 12500);
preg_match will return 0 for the hard coded regular expression.
but if I set $text to 12499, it will return 1 for a match.
$text = str_repeat('*', 12499);
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |