首页 > 原创文章 > 软件开发 > 查看文章

js/php/java/python常用语法及函数

所属分类:软件开发 来源: 丁老师原创 更新时间:2025-10-22 08:36 浏览: 415 IP属地: 深圳
微信小程序开发
点击阅读全文

js

#replace替换
var str="Hello world! world is beautiful.";
var str_new=str.replace("world","JavaScript");
console.log(str_new);

#替换全部
var str="Apple, Banana, Apple, Orange";
const str_new=str.replace(/Apple/g,"Grape");
console.log(str_new); 

#忽略大小写
const str_new= str.replace(/hello/gi,"Hi");

#In Arrray
const arr=['apple','banana','cherry'];
console.log(arr.includes('banana'));

php

#replace
$str="Hello world! world is beautiful.";
$str_new=str_replace("world","PHP",$str);
echo $str_new; 

#忽略大小写
$str="Hello HELLO hello";
$str_new=preg_replace('/hello/i','Hi',$str);
echo $str_new;

#in_array
$arr=['apple','banana','cherry'];
in_array('banana',$arr);

java

#replace
String str="Hello world! world is beautiful.";
String str_new=str.replace("world", "Java");
System.out.println(str_new);

#in array
String[] arr={"apple", "banana", "cherry"};
List<String> list=Arrays.asList(arr); 

System.out.println(list.contains("banana"));

python

#replace
s="Hello world! world is nice."
s_new=s.replace("world", "Python")
print(new_s)

#in array
arr=['apple', 'banana', 'cherry']
print('banana' in arr)

相关文章

videojs宽度高度自适应100%的方法

videojs是一款非常不错的htmlvideo播放器插件,很多同学经常在群里问我,说丁老师这个videojs怎么设置为宽度或者高度自适应呢,不想把video的width和height写死,有没有什么办法呢。丁老师经过研究发现啊,vid...

fastadmin后台列表默认分页数量由10...

没那么多废话,直接上修改方法public\assets\js\require-table.jspageSize: Config.pagesize || localStorage.getItem("pagesize")...

微信小程序从开发到实现微信支付的全过程

微信小程序部分一、完善小程序基本信息1.用管理员账号登录微信小程序(https://mp.weixin.qq.com/);2.左侧菜单选择首页;3.完善小程序的基本信息,包括小程序名称、小程序类目、微信认证、微信备案等。二、小程序开发配...

fastadmin非菜单链接,跳转菜单页面的...

在fastadmin中,一个页面的非菜单链接,想要点击后打开指定页面,并且菜单自动展开,该怎么实现呢?经过丁老师研究后,发现超级简单,废话不多说,直接上代码:<a class="btn-addtabs" hre...

推荐文章

如何删除idea软件搜索时的find mas...

在使用idea系列的配套软件时,如intellijidea、PhpStorm、WebStrom时,在搜索文件时,右上角的filemask可以筛选指定类型的文件。但是有时候可能会输入错误,产生多个记录,而且没办法删除,在以后的开发中经常会耽误...

fastadmin add/edit方法不更...

问题:fastadmin的add/edit方法无法保存数据,检查了页面,name=row['name']正常传送,检查controller,也是默认的方法,什么也没有动可就是无法保存数据。解决:经过仔细研究发现,原来是htm...

微信小程序提示“手机号快速验证组件”资源包用...

微信小程序自2023年8月起,开始对《手机号快速验证组件》进行收费,每个小程序有1000次的免费额度,超过额度就要收费。说白了就是以后在使用微信小程序获取用户手机(用户主动授权)的时候,需要按次数收费了。那么,在当前的经济状况下,如何做到轻...

uniapp开发微信小程序时,微信开发者工具...

在使用uniapp开发微信小程序,微信开发者工具调试时,明明已经给了获取位置权限,但还是提示需要打开gps获取位置,具体解决办法如下:打开uniapp的manifest.json文件,切换到源码模式,找到mp-weixin节点"p...