BaseMax / BaseMax/PharmacyMVCPHP

سوال و پرسش - بررسی - نقد - پیشنهاد - نظر

Open
#1 9 comments 0 reactions 1 assignee Claimed by @0ahmadi View on GitHub
Dominant language
PHP
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

replace, regex

replace /\{([a-zA-Z]+)\}/ to ([^\/]+) or (?<$1>[^\/]+)

بعد که replace کردید حالا با regex
preg_match
چک کنید.

regex
و دو تا ورودی هارو لاگ بگیر.

خروجی preg هم لاگ کن.

$path = "/api/users/{id}";
$uri = "/api/users/12";

$newPath = str_replace("{id}", "([^\/]+)", $path);
$newPath = "\/api\/users\/([^\/]+)";
var_dump(
preg_match('/^' . $newPath . '$/', $uri, $matches)
);

$newPath = "\/api\/users\/([^\/]+)";

replace '/' to '\/'

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.