﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Релиб / Веб-программирование / Perl  / есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ? / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Релиб</description><link>http://www.relib.com/forums/</link><webMaster>robot@relib.com</webMaster><lastBuildDate>Sat, 22 Nov 2008 19:25:20 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>спасибо за решение. &lt;BR&gt;btw, если интересно, еще альтернатива, с использованием substr в левой части:substr( $chg_where, index ($chg_where, $chg_what), length($chg_what) ) = &amp;quot;__SUBGRP__&amp;quot;;</description><pubDate>Mon, 07 Feb 2005 11:45:00 GMT</pubDate><dc:creator>offender</dc:creator></item><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>т.е.&lt;BR&gt;[code]&lt;BR&gt;$here = quotemeta($here);&lt;BR&gt;s/$here/$not_there/&lt;BR&gt;[/code]</description><pubDate>Fri, 04 Feb 2005 18:39:00 GMT</pubDate><dc:creator>Padmiv</dc:creator></item><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>попробуй [code]s/quotemeta($here)/$not_there/[/code]</description><pubDate>Fri, 04 Feb 2005 18:38:00 GMT</pubDate><dc:creator>Padmiv</dc:creator></item><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>но код делает не то, что нужно.&lt;BR&gt;(действие кода понятно. )вот &amp;quot;измененный под задачу&amp;quot; код  - обратите внимание, что ключ хеша, а не значение, содержит символы, трактуемые в s/// как специальные символы паттерна.Виноват, сразу не акцентировал проблему - необходимо _игнорировать_ специальные значения символов в паттерне s/$here/$not_there/ ########################################&lt;BR&gt;$str_where = &amp;quot;select t.*, rownum from dual t where exists (select * from dual where '1'&amp;lt;&amp;gt;'0')&amp;quot;;&lt;BR&gt;my %HASH;$HASH{&amp;quot;(select * from dual where '1'&amp;lt;&amp;gt;'0')&amp;quot;} = &amp;quot;_Must_Be__&amp;quot;;foreach my $key(keys %HASH) {&lt;BR&gt;  $str_where =~ s/$key/$HASH{$key}/;&lt;BR&gt;}&lt;BR&gt;print  $str_where;&lt;BR&gt;########################################&lt;BR&gt;#  - желаемый рез-т :&lt;BR&gt;# select t.*, rownum from dual t where exists _Must_Be__&lt;BR&gt;#спасибо за ответ.</description><pubDate>Thu, 03 Feb 2005 12:43:00 GMT</pubDate><dc:creator>offender</dc:creator></item><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>Нет ничего невозможного. В Perl для этого идеально подходят хэши.&lt;BR&gt;На вскидку - можно сделать так:$str_where = &amp;quot;select t.*, rownum from dual t where exists _REPLACE_THIS_&amp;quot;;&lt;BR&gt;my %HASH;$HASH{'_REPLACE_THIS_'}= &amp;quot;(select * from dual where '1'&amp;lt;&amp;gt;'0')&amp;quot;;foreach my $key(keys %HASH) {       $str_where= ~s/$key/$HASH{$key}/;}Надеюсь эействие кода понятно.</description><pubDate>Thu, 03 Feb 2005 09:28:00 GMT</pubDate><dc:creator>PoizOn</dc:creator></item><item><title>RE: есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>уточню:$str_where =~ s/$str_what/__STR_WITH__/;не подойдет, т.к. в ходе поиска специальные значения символов &lt;BR&gt;()/\{}*.?  etc. etc.&lt;BR&gt;мешают.</description><pubDate>Wed, 02 Feb 2005 20:44:00 GMT</pubDate><dc:creator>offender</dc:creator></item><item><title>есть ли в regexp аналог Replace( Str_where, Str_what, Str_with) ?</title><link>http://www.relib.com/forums/Topic855531-18-1.aspx</link><description>есть переменные &lt;BR&gt;$str_where = &amp;quot;select t.*, rownum from dual t where exists (select * from dual where '1'&amp;lt;&amp;gt;'0') &amp;quot;;$str_what = &amp;quot;(select * from dual where '1'&amp;lt;&amp;gt;'0')&amp;quot;;&lt;BR&gt;$str_with = &amp;quot;__REPLACED_SUBQUERY__&amp;quot;;есть ли возможность получить в результате строку&lt;BR&gt;&amp;quot;select t.*, rownum from dual t where exists __REPLACED_SUBQUERY__&amp;quot; заранее спасибо за помощь.</description><pubDate>Wed, 02 Feb 2005 19:29:00 GMT</pubDate><dc:creator>offender</dc:creator></item></channel></rss>