#### Category : regex

I wanted to validate whether the course field starts with an alphabet or not.How can i do that? what regex shall i try for that? $validator = Validator::make($request->all(), [ ‘course’ => ‘required|alpha_dash|min:2’ ], ); Sourc..

We have a multiple route in laravel and one of our url we have this url: http://sample.com/U9JD1 as our short urls, here this shorted url string length is fixed by 5 character and that could be both of string and number like with U9JD1 now how can i use where clause in this route: Route::get(‘{shortCode?}’, ..

hello i have laravel blade and here is the part that have the issue @php $reg_exUrl = "/(http|https|ftp|ftps)://[a-zA-Z0-9-.]+.[a-zA-Z]{2,3}(/S*)?/"; @endphp <div class="message"> @php$text = nl2br(e($message)); @endphp @if(preg_match($reg_exUrl, $text,$url)){!! preg_replace($reg_exUrl, ‘<a href="$0" target="_blank">$0</a> ‘,$text) !!} @else {!!$text!!} @endif </div> this works good if the link is only in the text but if it got .. Read more In Laravel, we can use the * wildcard notation for validating input from arrays:$validator = Validator::make($request->all(), [ ‘person.*.email’ => ’email|unique:users’, ‘person.*.first_name’ => ‘required_with:person.*.last_name’, ]); What is the simplest way to access all keys matching the input using the same notation? For example, using "person.*.email" I want to retrieve ["person.0.email", "person.1.email] if there are two .. Read more I want to create a regular expression which should satisfy below requirement. a-z and A-Z allowed. 0-9 allowed. no capital letters is allowed. no special chars, no space. no 2 repeating chars allowed. length should be between 6-9 length. here are some example abcdef – allowed abc456 – allowed aabc123 – not allowed because 2 .. Read more I would like to parse out language strings from blade files ({{ __(‘some phrase’) }}) and store them automatically in language files. I did try a plugin related to this which worked alright but did not allow functions to be ran. I created the below regex. { // Opening curly brace (?:s+?)? // Optional spacing .. Read more Here is what it looks like after getting value from CDATA via simplexmlelement$data = "{customertype=New, Telephone=09832354544, CITY=Henfield, LASTNAME=C, TicketNo=123456, FIRSTNAME=Alex, Id=10001273, testfield=123456, COMPANY=Camp1}" I tried looking into solutions in google but i am not able to find one which would convert this set of strings to array. I want this data to convert into ..

Im web.php, I have working routes. Route::get(‘post/{post?}/{id?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{tag:slug?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{user?}/{id?}’, [PostController::class, ‘__invoke’]); Route::get(‘post/{location?}’, [PostController::class, ‘__invoke’]); And I wanted it a little bit shorter. Route with post parameter working fine but the two others got 404. Route::get(‘post/{post?}/{id?}’, [PostController::class, ‘__invoke’]) ->where(‘post|id’, ‘tag:slug|user|location’); In RouteServiceProvider.php, I have bind two route with their parameters. Route::bind(‘post’, function ..

Im web.php, I have working routes. Route::get(‘post/{post?}/{id?}’, PostController::class); Route::get(‘post/{tag:slug?}’, PostController::class); Route::get(‘post/{user?}/{id?}’, PostController::class); Route::get(‘post/{location?}’, PostController::class); And I wanted it shorter. Route with post parameter working fine but the others got 404. Route::get(‘post/{post?}/{id?}’, PostController::class) ->where(‘post|id’, ‘tag:slug|user|location’); In RouteServiceProvider.php, I have route binding for post and user parameters. Here is my PostController.php public function __invoke(Request $request, Post$post ..

I have String [{"checkin":"uiyuiy","checkout":"uihiuyh"},{"checkin":"somethingin","checkout":"somethingout"}] and I want to use foreach loop this string how can I achieve in laravel Sourc..

How would I achieve this with something like the preg_replace() function? Sourc..

I am currently using Laravel 8 and doing form validation using the built in available validation rule regex. Currently this project is not able to be edited. So no creating new validation rules using the php artisan make:rule command. The reason for this is because I’m currently using Pterodactyl Panel (which is a video game ..

private function getCategoryIdsFromNames($categories,$subCategory){ $categoryArray =$this->explode($categories); if(!$categoryArray) return false; $categoryIds = []; foreach ($categoryArray as $categoryName){$category = CategoryTranslation::query()->where(‘name’,$categoryName)->where(‘locale’,’en’)->first(); if($category){ $categoryIds[] =$category->category_id; }else{ $newCategory = [ ‘name’=>$categoryName, ‘is_active’=>"1", ‘parent_id’=>null, ‘is_searchable’=>"1", ]; $category = Category::query()->create($newCategory); $categoryIds[] =$category->id; } } return $categoryIds; } This code currently importing one category for one product. I want to .. Read more I am trying to get user code from package label which contains address and 6 digit and sometimes 2 prefix with 6 digit. First of all i am getting label image then with help of aws textract, i take text. But inside of text there can be sometimes 6 digit another code. tried regex (sd{6}s)|((.)d{6}s)|(s[a-zA-Z]{2}d{6}s) .. Read more I have a viewers JSON column in the products table that hold a similar value example: [{"at": "2021-06-21T18:58:39", "age": 30, "country_iso_code": "US"}, {"at": "2021-06-18T11:13:13", "age": 20, "country_iso_code": "PH"}, {"at": "2021-06-25T23:57:12", "age": 45, "country_iso_code": "ET"}, {"at": "2021-06-27T17:01:14", "age": 18, "country_iso_code": "DZ"} So, I’m trying to get rows that contain numbers between two JSON age property values, .. Read more i need regex to check that string is following format like this: 78 (can be numeric/integer) or 8.9 (can be float) or 78|8.9|100 What is the best regex for that?Thank you in advance Sourc.. Read more I want to insert some data or lines in a file in a specific place For example, I have a file in the laravel project called web.php which is a route file and I want to edit it programmatically and insert a new route within a route group. So what regex I can use to .. Read more recently I have difficulty replacing every <img> tag src to the data-lazyload-src. My expected output will be <img src="facebook.com/image.png" class="img big-img" data-lazyload-src="tt.com/image_01_140x140.png"/> to <img class="img big-img" src="tt.com/image_01_140x140.png"/> I know these can be done by using PHP preg_replace but I am quite new to regex. Meanwhile, I would like to replace it completely in backend instead .. Read more Some users want to add emojis, but we don’t want to store in database, instead we want to convert it like below 😊 => 🙂 🙁 => 🙁 😁 => 😀 😥 => ;( 😮 => :O 😉 => 😉 😎 => 8) is it possible to change all emojis like above? Do you know .. Read more I have a student result file I want to search from there with student roll to show the result next to that roll.. The format of my result sheet 300001 (3.63) 300002 (3.28) 300011 {66672 (T)} 300017 {66641 (T), 66652 (T), 66672 (T), 66678 (T)} Here 300001 is a roll and the result of the .. Read more I need a regex for laravel validation to control my username input not be an email address any help plz? <input type="text" placeholder="Don’t type email address for your usename" name="username"></input> my Laravel validation for username input ‘username’ => ‘required|min:5|regex:?’ Sourc.. Read more I am developing one API which is responsible for registering the users and the data should store in database upto this part it’s working fine, i want to add regex patterns for validation part ,for example if the user mobile number not matches with the regex pattern then it should return a response like Please .. Read more i go this view file that only working to upload image types file, need help to make it can do upload different extension of file leets says .doc or .pdf thank you controler: public function pengajuan_baru_post() if($layanan->dokumenLayanan->count() > 0){ if($this->request->has([‘dokumen_id’, ‘dokumen’])){ foreach ($this->request->dokumen as $dok) { if(!empty($dok)){ if(empty(preg_match(‘/^data:image/(?<extension>(?:png|gif|jpg|jpeg|webp));base64,(?<image>.+)$/’,$dok))){ return back()->with(‘warning’, ‘Pastikan format dokumen yang ..
I have 2 regular expressions in the database: 1. ^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bc1)[0-9A-Za-z]{39,59}$ 2. ^(bnb1)[0-9a-z]{38}$that I use for validation as the following code$this->validate([ ‘address’ => ‘required|regex:/’.\$this->networkData->address_regex.’/’, ]); There is no problem with the second regex But for the first regex the following error is given preg_match(): No ending delimiter ‘/’ found There were many questions for ..