输入:
古杰拉特(24)
输出:
古杰拉特
字符串格式
州名(州代码)
我想用括号删除状态代码。如何通过在PHP中使用正则表达式来做到这一点?
答案 0 :(得分:2)
您可以尝试
select t.mon$table_name,trim(
case when r.mon$record_seq_reads>0 then 'Non index Reads: '||r.mon$record_seq_reads else '' end||
case when r.mon$record_idx_reads>0 then ' Index Reads: '||r.mon$record_idx_reads else '' end||
case when r.mon$record_inserts>0 then ' Inserts: '||r.mon$record_inserts else '' end||
case when r.mon$record_updates>0 then ' Updates: '||r.mon$record_updates else '' end||
case when r.mon$record_deletes>0 then ' Deletes: '||r.mon$record_deletes else '' end)
from MON$TABLE_STATS t
join mon$record_stats r on r.mon$stat_id=t.mon$record_stat_id
where t.mon$table_name not starting 'RDB$' and r.mon$stat_group=2
order by 1
说明
(?<=\s)(\(.*\))
-积极回望。匹配(?<=\s)
(空格)。\s
-匹配(\(.*\))
答案 1 :(得分:1)
使用RegEx
array(2) {
[0]=>
string(91) "https://eksisozluk.com/merve-sanayin"
[1]=>
string(91) "https://eksisozluk.com/merve-sanayin"
[2]=>
}
答案 2 :(得分:0)
也尝试一下。
$text="GUJARAT (24)";
$statename= preg_replace("/[(][0-9]*[)]/","",$text);
echo $statename;
答案 3 :(得分:0)
如果您不想使用正则表达式,也可以使用简单的strpos和substr。
与使用正则表达式相比,这是一种更轻松的方法(减少内存消耗)。
该代码找到class Role extends Model
{
protected $table = 'roles';
protected $fillable = [
'role'
];
public function user()
{
return $this->hasMany('App\User');
}
}
,并将所有内容往后移一步。
class User extends Authenticatable
{
use Notifiable;
protected $fillable = [
'name', 'email', 'password', 'role_id'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function payments()
{
return $this->hasMany('App\Models\Payment');
}
public function roles()
{
return $this->belongsTo('App\Models\Role');
}
}