strReplace

検索文字列に一致したすべての文字列を置換します。

構文
  1. return = strReplace( search, replace, subject )
引数
search
探したい値
replace
見つかった search を置き換える値
subject
検索・置換の対象となる文字列あるいは配列
戻値
置換後の文字列あるいは配列

プログラム

////////////////////////////////////////////////// // 【引数】 // search : 探したい値 // replace : 見つかった search を置き換える値 // subject : 検索・置換の対象となる文字列あるいは配列 // 【戻値】 // 置換後の文字列あるいは配列 ////////////////////////////////////////////////// FUNCTION strReplace(search, replace, subject) SELECT VARTYPE(subject) AND $2000 CASE $2000 // 配列 FOR n = 0 TO UBound(subject) subject[n] = REPLACE(subject[n], search, replace) NEXT RESULT = SLICE(subject) DEFAULT // 配列以外 RESULT = REPLACE(subject, search, replace) SELEND FEND ////////////////////////////////////////////////// // 【引数】 // 配列 : 上限値を求める配列 // 【戻値】 // 配列の上限値 ////////////////////////////////////////////////// FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND

プログラム実行例

指定されたサービスを開始および停止できるかどうかを返す

DIM Shell = CREATEOLEOBJ("Shell.Application") DIM arr = SPLIT(DOSCMD("sc query state=all | findstr /i service_name"), "<#CR>") arr = strReplace("SERVICE_NAME: ", "", arr) FOR n = 0 TO UBound(arr) PRINT arr[n] + "<#TAB>" + Shell.CanStartStopService(arr[n]) NEXT ////////////////////////////////////////////////// // 【引数】 // search : 探したい値 // replace : 見つかった search を置き換える値 // subject : 検索・置換の対象となる文字列あるいは配列 // 【戻値】 // 置換後の文字列あるいは配列 ////////////////////////////////////////////////// FUNCTION strReplace(search, replace, subject) SELECT VARTYPE(subject) AND $2000 CASE $2000 // 配列 FOR n = 0 TO UBound(subject) subject[n] = REPLACE(subject[n], search, replace) NEXT RESULT = SLICE(subject) DEFAULT // 配列以外 RESULT = REPLACE(subject, search, replace) SELEND FEND ////////////////////////////////////////////////// // 【引数】 // 配列 : 上限値を求める配列 // 【戻値】 // 配列の上限値 ////////////////////////////////////////////////// FUNCTION UBound(array[]) RESULT = RESIZE(array) FEND
結果
AdobeARMservice	False
AJRouter	False
ALG	False
ALUpdateService	False
AppHostSvc	False
AppIDSvc	False
Appinfo	False
AppReadiness	False
AppXSvc	False
aspnet_state	False
AudioEndpointBuilder	False
Audiosrv	False
autotimesvc	False
AxInstSV	False
BDESVC	False
BFE	False
BITS	False
BrokerInfrastructure	False
BTAGService	False
BthAvctpSvc	False
bthserv	False
camsvc	False
CDPSvc	False
CertPropSvc	False
CLHNService	False
ClipSVC	False
COMSysApp	False
CoreMessagingRegistrar	False
cphs	False
CryptSvc	False
CypherGuard cguard Service 32bit Edition	False
CypherGuard cguard Service 64bit Edition	False
CypherGuard Info Service	False
dbupdate	False
dbupdatem	False
DbxSvc	False
DcomLaunch	False
defragsvc	False
DeviceAssociationService	False
DeviceInstall	False
DevQueryBroker	False
Dhcp	False
diagnosticshub.standardcollector.service	False
diagsvc	False
DiagTrack	False
DispBrokerDesktopSvc	False
DisplayEnhancementService	False
DmEnrollmentSvc	False
dmwappushservice	False
Dnscache	False
DoSvc	False
dot3svc	False
DPS	False
DsmSvc	False
DsSvc	False
DusmSvc	False
Eaphost	False
EFS	False
embeddedmode	False
EntAppSvc	False
EventLog	False
EventSystem	False
Everything	False
Fax	False
fdPHost	False
FDResPub	False
fhsvc	False
FontCache	False
FontCache3.0.0.0	False
FrameServer	False
Freemake Improver	False
FreemakeVideoCapture	False
GoogleChromeElevationService	False
GoogleIMEJaCacheService	False
gpsvc	False
GraphicsPerfSvc	False
gupdate	False
gupdatem	False
hidserv	False
HvHost	False
icssvc	False
IDriverT	False
IKEEXT	False
ImeDictUpdateService	False
InstallService	False
iphlpsvc	False
IpxlatCfgSvc	False
KeyIso	False
KtmRm	False
LanmanServer	False
LanmanWorkstation	False
lfsvc	False
LicenseManager	False
LLHDClient	False
LLHDCloader	False
lltdsvc	False
lmhosts	False
LMS	False
LSM	False
LxpSvc	False
MapsBroker	False
MixedRealityOpenXRSvc	False
MozillaMaintenance	False
mpssvc	False
MSDTC	False
MSiSCSI	False
msiserver	False
MSMQ	False
MSSQL$SQLEXPRESS	False
MSSQLServerADHelper100	False
NaturalAuthentication	False
NcaSvc	False
NcbService	False
NcdAutoSetup	False
Netlogon	False
Netman	False
NetMsmqActivator	False
NetPipeActivator	False
netprofm	False
NetSetupSvc	False
NetTcpActivator	False
NetTcpPortSharing	False
NgcCtnrSvc	False
NgcSvc	False
NielsenUpdate	True
NlaSvc	False
nsi	False
nurago InstallUpdate	False
nurago NetworkMeter	False
nurago Reporting Service	False
ose64	False
osppsvc	False
p2pimsvc	False
p2psvc	False
PBExtractService	False
PcaSvc	False
perceptionsimulation	False
PerfHost	False
PhoneSvc	False
pla	False
PlugPlay	False
PNRPAutoReg	False
PNRPsvc	False
PolicyAgent	False
Power	False
PrintNotify	False
ProfSvc	False
PushToInstall	False
QWAVE	False
RasAuto	False
RasMan	False
RemoteAccess	False
RemoteRegistry	False
RetailDemo	False
RmSvc	False
RpcEptMapper	False
RpcLocator	False
RpcSs	False
SamSs	False
SCardSvr	False
ScDeviceEnum	False
Schedule	False
SCPolicySvc	False
SDRSVC	False
seclogon	False
SecurityHealthService	False
SEMgrSvc	False
SENS	False
SensorDataService	False
SensorService	False
SensrSvc	False
SessionEnv	False
SgrmBroker	False
SharedAccess	False
SharedRealitySvc	False
ShellHWDetection	False
shpamsvc	False
smphost	False
SmsRouter	False
SNMPTRAP	False
spectrum	False
Spooler	False
sppsvc	False
SQLAgent$SQLEXPRESS	False
SQLBrowser	False
SQLWriter	False
SSDPSRV	False
ssh-agent	False
SstpSvc	False
StateRepository	False
stisvc	False
StorSvc	False
svsvc	False
swprv	False
SynTPEnhService	False
SysMain	False
SystemEventsBroker	False
SystemExplorerHelpService	False
TabletInputService	False
TapiSrv	False
TeamViewer	False
TermService	False
Themes	False
TieringEngineService	False
TimeBrokerSvc	False
TMachInfo	False
TODDSrv	False
TokenBroker	False
TosCoSrv	False
TOSHIBA eco Utility Service	False
TOSHIBA HDD SSD Alert Service	False
TosRzTfSvc	False
TPCHKarteSVC	False
TPCHSrv	False
TrkWks	False
TroubleshootingSvc	False
TrustedInstaller	False
tzautoupdate	False
UmRdpService	False
UNS	False
upnphost	False
UserManager	False
UsoSvc	False
VacSvc	False
VaultSvc	False
vds	False
vmicguestinterface	False
vmicheartbeat	False
vmickvpexchange	False
vmicrdv	False
vmicshutdown	False
vmictimesync	False
vmicvmsession	False
vmicvss	False
VSS	False
VSStandardCollectorService150	False
W32Time	False
w3logsvc	False
W3SVC	False
WaaSMedicSvc	False
WalletService	False
WarpJITSvc	False
WAS	False
wbengine	False
WbioSrvc	False
Wcmsvc	False
wcncsvc	False
WdiServiceHost	False
WdiSystemHost	False
WdNisSvc	False
WebClient	False
Wecsvc	False
WEPHOSTSVC	False
wercplsupport	False
WerSvc	False
WFDSConMgrSvc	False
WiaRpc	False
WinDefend	False
WinHttpAutoProxySvc	False
Winmgmt	False
WinRM	False
wisvc	False
WlanSvc	False
wlidsvc	False
wlpasvc	False
WManSvc	False
wmiApSrv	False
WMPNetworkSvc	False
workfolderssvc	False
WpcMonSvc	False
WPDBusEnum	False
WpnService	False
wscsvc	False
WSearch	False
wuauserv	False
WwanSvc	False
XblAuthManager	False
XblGameSave	False
XboxGipSvc	False
XboxNetApiSvc	False
AarSvc_64da0	False
BcastDVRUserService_64da0	False
BluetoothUserService_64da0	False
CaptureService_64da0	False
cbdhsvc_64da0	False
CDPUserSvc_64da0	False
ConsentUxUserSvc_64da0	False
CredentialEnrollmentManagerUserSvc_64da0	False
DeviceAssociationBrokerSvc_64da0	False
DevicePickerUserSvc_64da0	False
DevicesFlowUserSvc_64da0	False
MessagingService_64da0	False
OneSyncSvc_64da0	False
PimIndexMaintenanceSvc_64da0	False
PrintWorkflowUserSvc_64da0	False
UnistoreSvc_64da0	False
UserDataSvc_64da0	False
WpnUserService_64da0	False

この記事は役に立ちましたか?
役に立った 役に立たなかった