You can easily use preg here: there are several options available. among them are: option 1: $find = '#<loc>http://mydomain\.com/myfile\.php</loc>\r\n<lastmod>.{10}</lastmod>#'; option 2: $find = '#<loc>http://mydomain\.com/myfile\.php</loc>\r\n<lastmod>\d{4}-\d{2}-\d{2}</lastmod>#';
option 3: $find = '#<loc>http://mydomain\.com/myfile\.php</loc>\r\n<lastmod>.*?</lastmod>#'; $replace ='<loc>http://mydomain\.com/myfile.php</loc>\r\n<lastmod>2007-01-01</lastmod>'; $str = preg_replace ( $find, $replace, $str ); Pete <[EMAIL PROTECTED]> wrote: In message <[EMAIL PROTECTED]> , Wes G <[EMAIL PROTECTED]> writes >that's odd no wildcard available. Did you try a % instead of a * ? No - not at the time. But I have now, and % doesn't work for me in str_replace(). Should it? > > On 11/5/05, Pete <[EMAIL PROTECTED]> wrote: >> >> >> I want to change a single line in a text file, so I have: >> >> $find="<loc>http://mydomain.com/myfile.php</loc>\r\n<lastmod>2006-01-01< >> /lastmod>"; >> >> $replace="<loc>http://mydomain.com/myfile.php</loc>\r\n<lastmod>2007-01- >> 01</lastmod>"; >> >> Then: >> $result = str_replace($find, $replace, $file); >> >> >> I need line breaks because I have to change the date in the second line, >> depending on the filename in the first line. It's on a Windows machine, >> so the newline works fine. >> >> BUT - I don't know the date in $find. I really need something like >> $find="<loc>http://mydomain.com/myfile.php</loc>\r\n<lastmod>****-**-**< >> /lastmod>"; >> wildcards..! but that isn't available. And I can't see how preg_replace >> would work here. >> >> Any suggestions? >> >> -- >> Pete Clark >> >> >> >> Community email addresses: >> Post message: [email protected] >> Subscribe: [EMAIL PROTECTED] >> Unsubscribe: [EMAIL PROTECTED] >> List owner: [EMAIL PROTECTED] >> >> Shortcut URL to this page: >> http://groups.yahoo.com/group/php-list >> >> >> >> SPONSORED LINKS >> Job >> postings<http://groups.yahoo.com/gads?t=ms&k=Job+postings&w1=Job+posting >s&c=1&s=18&.sig=3mNuDqhcdaFoXoe-LEll0g> >> ------------------------------ >> YAHOO! GROUPS LINKS >> >> >> - Visit your group "php-list<http://groups.yahoo.com/group/php-list>" >> on the web. >> - To unsubscribe from this group, send an email to: >> [EMAIL PROTECTED]<[EMAIL PROTECTED] >ubject=Unsubscribe> >> - Your use of Yahoo! Groups is subject to the Yahoo! Terms of >> Service <http://docs.yahoo.com/info/terms/>. >> >> >> ------------------------------ >> > > > >-- >Thanks, >Wes >http://www.gmail.com > > >[Non-text portions of this message have been removed] > > > > >Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > >Shortcut URL to this page: > http://groups.yahoo.com/group/php-list >Yahoo! Groups Links > > > > > > > > -- Pete Clark http://www.hotcosta.com http://www.spanishholidaybookings.com Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list SPONSORED LINKS Job postings --------------------------------- YAHOO! GROUPS LINKS Visit your group "php-list" on the web. To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. --------------------------------- --------------------------------- Yahoo! FareChase - Search multiple travel sites in one click. [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income households are not online. Help bridge the digital divide today! http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/HKFolB/TM --------------------------------------------------------------------~-> Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
